How open new activity clicking an item in listview?

前端 未结 10 2080
我在风中等你
我在风中等你 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:39

    You need to use Intent, You can also pass the clicked listview item data to your new activity.

    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" };
    
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView adapterView, View view, int i, long l) {                   
    Intent intent = new Intent(getApplicationContext(),ApkInfoActivity.class);
                    intent.putExtra("name",classes[i]);
                    startActivity(intent);
    
    
            }
        });
    
    }
    

    Output:

    You can find the whole tutorial here

提交回复
热议问题