Start an activity from a listview

前端 未结 2 1862
孤独总比滥情好
孤独总比滥情好 2021-01-16 19:25

Hi I have a listview and, I am trying to start an activity from the listview by startActivity(class.java);

public class ll2 extends Activity {

         


        
2条回答
  •  忘掉有多难
    2021-01-16 20:04

    MyList()[position] should be myList[position].
    Next you can not start an activity like this startActivity(Bradford.java);. For starting a new activity you need to create and intent and then set the Activity class. Then you can call startActivity with that intent.

    Intent intent = new Intent();
    intent.setClass(this, Bradford.class);
    startActivity(intent);
    And you need to add Bradford activity to your manifest as well.

提交回复
热议问题