문제

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

도움이 되었습니까?

해결책

try Below Code

if (position == 0){
    Intent intent = new Intent(YourActivity.this,ActivityToStart.class);
     startActivity(intent);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top