Pass Listview selection from one class to another and change button text
<p>I have a class with a <code>ListView</code>. Once the user makes a selection I want to pass that selection to the button on the previous class. This is what I have so far:</p>

<pre><code>public class SetupNewCourse extends Activity {
    String[] tees;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setup_new_course);

        final Button b = (Button) findViewById(R.id.button1);
        b.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent i = new Intent(SetupNewCourse.this, selectTee.class);
                startActivity(i);
                // following code is the hang up I know its in the wrong place
                selectTee buttonText = new selectTee();
                buttonText.returnTeeSelection();
                b.setText((CharSequence) buttonText);
            };
        });
    }
}
</code></pre>

<p>Following is my <code>ListView</code> class</p>

<pre><code>public class selectTee extends ListActivity {

    String[] tees_list;
    String selectedText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        tees_list = getResources().getStringArray(R.array.tees_array);
        setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.list_view,
                tees_list));
        final ListView teelist = getListView();
        teelist.setChoiceMode(1);
        teelist.setTextFilterEnabled(false);
        teelist.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView&lt;?&gt; teeAdapter, View arg1, int selectedInt, long selectedLong) {
                selectedText = (String) (teelist.getItemAtPosition(selectedInt));
                Toast.makeText(getApplicationContext(), ((TextView) arg1).getText(), Toast.LENGTH_SHORT).show();
                System.out.println(selectedText);
                finish();
            }
        });
    }

    public String returnTeeSelection() {
        return selectedText;
    }
}
</code></pre>

<p>Any help would be appreciated.<br>
Thanks in advance.</p>
