Android ListView, start new activity

后端 未结 2 1271
暗喜
暗喜 2021-01-29 04:59

Hey can someone tell me how I can start an activity by pressing an item in a listview?

Here is a hunch I have:

EDIT- I have fixed it i think bec

2条回答
  •  执笔经年
    2021-01-29 05:20

    You are passing an Activity as the argument to the startActivity() function

    startActivity(MenuActivity.class)
    

    Instead you should be passing it an Intent like this

    Intent myIntent = new Intent(Videos.this, MenuActivity.class);
    startActivity(myIntent);
    

提交回复
热议问题