How open new activity clicking an item in listview?

前端 未结 10 2096
我在风中等你
我在风中等你 2020-11-30 10:17

I can\'t start a new activity clicking over an item in my listview. I want that onItemClick can open the ApkInfoActivity.. Actually when i click no

10条回答
  •  半阙折子戏
    2020-11-30 10:54

    public class MenuYangu extends ListActivity {
    
    String classes[] = { "Quiz Trivia", "Sign A New User", "Friend List",
    "Download A File", "Upload A File", "Select Pdf files", "Memory Game",
    "Dzidza Maths", "Write Exam" };
    
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
       // TODO Auto-generated method stub
       super.onCreate(savedInstanceState);
       setListAdapter(new ArrayAdapter(Menuone.this,
       android.R.layout.simple_list_item_1, classes));
    
    }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) 
    {
         // TODO Auto-generated method stub
         super.onListItemClick(l, v, position, id);
    
    if (position == 0) {
    Intent intent = new Intent(this, QuizActivity.class);
    startActivity(intent);
    }
    else if (position == 1) {
    Intent intent = new Intent(this, SignUp.class);
    startActivity(intent);
    }
     else if (position == 2) {
     Intent intent = new Intent(this, FriendList.class);
     startActivity(intent);
     } 
     }
    
     }
    
     }
    

提交回复
热议问题