Android ListView, start new activity

后端 未结 2 1272
暗喜
暗喜 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);
    
    0 讨论(0)
  • 2021-01-29 05:40

    Make sure you are adding the activity to the Android manifest In your manifest file you should add the activity like this:

    <activity android:name=".Lars"/>
    

    make sure to do this for each Intent and activity you plan to use.

    0 讨论(0)
提交回复
热议问题