Android ListView更改活动

时间:2015-03-10 13:05:12

标签: android listview android-intent

我的代码:

    String[] category = {"CA", "Tax consultant", "MR", "Dance trainer"};
    ListAdapter categoryAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, category);
    ListView categoryListView = (ListView) findViewById(R.id.categoryListView);
    categoryListView.setAdapter(categoryAdapter);

如果单击一个项目,我会写什么来更改活动。请告诉我在新活动中写什么?

1 个答案:

答案 0 :(得分:0)

使用此代码:

categoryListView.setOnItemClickListener(new OnItemClickListener
{
    @override
    public void onClick(int position)
    {
      startActivity(new Intent(getBaseContext(), NewActivity.class));
    }
});