Domanda

   @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.

È stato utile?

Soluzione

try Below Code

if (position == 0){
    Intent intent = new Intent(YourActivity.this,ActivityToStart.class);
     startActivity(intent);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top