Hi I created the list successfully but my problem is when ever i select an item in the list it is not moving to another layout. In that layout i created a button and text view. can any one help me below iam placing my code.
//In this code wheneven i select the second option from the list it has to go to another layout where one text view will be there. public class SList extends ListActivity implements OnItemClickListener { final String[] items = new String[]{ "First","Second" }; ListView lv = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,items)); lv = getListView(); lv.setChoiceMode(lv.CHOICE_MODE_SINGLE); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(this); } /*protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); int pos = position; String str = (String) lv.getItemAtPosition(pos); if(str == "First") { setContentView(R.layout.second); } }*/ public void onItemClick(AdapterView parent, View v, int postion, long id) throws NullPointerException { int pos = postion; String str = (String)lv.getItemAtPosition(pos); if(str.equals("Second")) { setContentView(R.layout.main); TextView tv = null; tv = (TextView)findViewById(R.id.TextView01); tv.setText("Hello"); setContentView(tv); } } //In this code wheneven i select the second option it has to go to another layout where one text view will be there. please help me -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en