Note that there are some explanatory texts on larger screens.

plurals
  1. POfindViewById other layout
    primarykey
    data
    text
    <p>I have 2 xml, the name is formOne.xml and formTwo.xml</p> <p>formOne.xml look like this :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:paddingLeft="16dp" android:paddingRight="16dp"&gt; &lt;EditText android:id="@+id/editTextName" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;/LinearLayout&gt; </code></pre> <p>and fomTwo.xml :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:paddingLeft="16dp" android:paddingRight="16dp"&gt; &lt;Button android:id="@+id/buttonSave" android:layout_width="120dp" android:layout_height="wrap_content" android:text="@string/btSave" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>and i have two activity, the name is FormOne.java and FormTwo.java</p> <p>FormOne.java :</p> <pre><code>public class FormOne extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.formOne); EditText etName = (EditText) findViewById(R.id.editTextName); } </code></pre> <p>}</p> <p>and FormTwo.java :</p> <pre><code>public class FormTwo extends Activity implements OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.formTwo); EditText etName = (EditText) findViewById(R.id.editTextName); Button btSave = (Button) findViewById(R.id.buttonSave); btSimpan.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (etName.getText().length() != 0) { Toast.makeText(FormTwo.this, "Name is : "+etName.getText().toString(), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(FormTwo.this, "Input the name please", Toast.LENGTH_SHORT).show(); } // TODO Auto-generated method stub } }); } </code></pre> <p>i want to catch value from editTextName, and value can show in FormTwo.java with Toast.</p> <p>but myapplication force close, how i can to get value editTextName, without passing data with bundle. because in FormOne.java not any button to send value editTextName.</p> <p>Thanks in Advance </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload