2011-06-24 4 views
0

j'ai problème avec mon application Android, j'ai cherché, mais ne peut pas trouver réponse, j'ai ce code:Android ListView à l'activité suivante ListView

public class Matematika extends ListActivity { 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     String[] mStrings = new String[]{"Mother", "Sister", "Brother"}; 

     // Create an ArrayAdapter, that will actually make the Strings above appear in the ListView 
     this.setListAdapter(new ArrayAdapter<String>(this, 
     android.R.layout.simple_list_item_1, mStrings)); 
    } 
} 

Et je veux faire par exemple ceci: je veux cliquer sur Mère et veulent aller ensuite ListActivity (nouvelle activité via l'intention si c'est réel), ListActivity, où est une autre option ....

Merci beaucoup.

Répondre

1
@Override 
    protected void onListItemClick(ListView lv, View v, int position, long id) { 
     super.onListItemClick(lv, v, position, id); 
     try { 
      switch (position) { 
      case 0: //Mother 
        //Launch MotherActivity 
        Intent motherIntent = new Intent(this, MotherListActivity.class); 
        startActivity(motherIntent); 
       break; 
      case 1: //Sister 
       //Call SisterActivity 
       Intent sisterIntent = new Intent(this, SisterListActivity.class); 
       startActivity(sisterIntent); 
       break; 
      case 2: //Brother 
       Intent brotherIntent = new Intent(this, BrotherListActivity.class); 
       startActivity(eventsIntent); 
       break; 
      } 
     } catch (Exception e) { 
      Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); 
     } 
    }