Question

   @Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    //get selected items
    String selectedValue = (String) getListAdapter().getItem(position);
    Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();

}

Hi everyone, I have got my listview done and i ve got the code for the onlistitemclick working so whenever i click on an item in my list the name of the item is displayed. What I want to do is to add more functionality lets say that when the first item of the list is clicked then another activity starts and so on for the rest. anyone knows how can i impement that? thanks for your help in advance is much appriciated.

Était-ce utile?

La solution

try Below Code

if (position == 0){
    Intent intent = new Intent(YourActivity.this,ActivityToStart.class);
     startActivity(intent);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top