So I have a ListAdapter
which has various options and what I want is that when a user clicks on the ListAdapter
an activity starts which has an EditText
and the EditText
should be automatically filled with option which was, clicked on for the ListAdapter
.
Currently I have Main.java:
public class Main extends ListActivity{
String options[] = {"option1","option2"};
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String> (Main.this,android.R.layout.simple_list_item_1,options);
}
protected void onListItemClick(ListView l,View v, int position, long id){
super.onListItemClick(l,v,position,id);
try{
Class theClass = Class.forname("com.example.SecondActivity");
Intent oI = new Intent(Main.this,theClass);
startActivity(oI);
}catch(ClassNotFoundException e){e.printStackTrace();}
}
SecondActivity.java (This contains the activity with the edit text):
public class SecondActivity extends Activity{
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContextView(R.layout.secondactivity)
EditText edt = (EditText) findViewById(R.id.edt1);
}
What all extra do I need to do so that this works. All the help is deeply appreciated.