Android issue: how to get content from edittext
<p>In my project. There are three files.</p>

<pre><code>passParaActivity.java 
//main Activity, show a edittext and a button to reslut.java
result.java 
//display the number which typed in passParaAcitivity.java
mainFunc.java 
//function to get the number from passParaActivity.java
</code></pre>

<p>This is the main.xml which relate to passParaActivity.java.</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" &gt;
   &lt;TextView android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:text="Type a number:"
             android:textSize="20dp"/&gt;
   &lt;EditText android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:hint="Type a number"
             android:id="@+id/number"/&gt;
   &lt;Button android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:text="PASS"
           android:id="@+id/btn"/&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>This is the code of result.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="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" &gt;

    &lt;TextView android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="The number is:"
              android:textSize="20dp"/&gt;
    &lt;TextView android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:textSize="30dp"
              android:textColor="#0000ff"
              android:id="@+id/mytext"/&gt;
    &lt;Button android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Back"
            android:id="@+id/back"/&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>passParaActivity.java:</p>

<pre><code> public Button btn;
    public EditText number;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn = (Button) findViewById(R.id.btn);
        number = (EditText) findViewById(R.id.number);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(PassParaActivity.this, result.class);
                startActivity(intent);
            }
        });
    }
</code></pre>

<p>result.java:</p>

<pre><code>public TextView mytext;
    public Button back;
    mainFunc main;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result);
        mytext = (TextView) findViewById(R.id.mytext);
        back = (Button) findViewById(R.id.back);

        main = new mainFunc(result.this);
        mytext.setText(main.getNum());

        back.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(result.this, PassParaActivity.class);
                startActivity(intent);
            }
        });
    }
</code></pre>

<p>mainFunc.java</p>

<pre><code>public class mainFunc {
    private PassParaActivity mycontext;
    int num = 0;
    public mainFunc(Context context){
        mycontext = (PassParaActivity) context;
    }

    public int getNum(){
        num = Integer.parseInt(mycontext.number.getText().toString());
        return num;
    }
}
</code></pre>

<p>How can I get this one working? Thanks for your patient.</p>
