Posted By

variable3 on 04/27/11


Tagged

list activity


Versions (?)

Android ListActivity


 / Published in: Java
 

  1. public class ListAct extends ListActivity {
  2. public final String[] subs={"Java",".net","php","Adv c"};
  3. under oncreate--
  4. this.setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,subs));
  5.  
  6. override onListItemClick--
  7. protected void onListItemClick(ListView l, View v, int position, long id) {
  8. super.onListItemClick(l, v, position, id);
  9. // Get the item that was clicked
  10. Object o = this.getListAdapter().getItem(position);
  11. String keyword = o.toString();
  12. Toast.makeText(this, "You selected: " + keyword,toast.LENGTH_LONG)
  13. .show();
  14. }

Report this snippet  

You need to login to post a comment.