Android ListView更改活动
我的代码:Android ListView更改活动,android,listview,android-intent,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) findViewB
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);
String[]category={“CA”、“税务顾问”、“MR”、“舞蹈教练”};
ListAdapter categoryAdapter=新的ArrayAdapter(这是android.R.layout.simple\u list\u item\u 1,category);
ListView categoryListView=(ListView)findViewById(R.id.categoryListView);
setAdapter(categoryAdapter);
单击单个项目时,我要写什么来更改活动。甚至告诉我在新活动中要写什么?使用以下代码:
categoryListView.setOnItemClickListener(new OnItemClickListener
{
@override
public void onClick(int position)
{
startActivity(new Intent(getBaseContext(), NewActivity.class));
}
});
当单击listview的任何项目时,是否要打开相同的活动?用谷歌搜索任何基本listview教程(在提问之前)。您需要实现onItemClicked方法。@apurva:没有其他活动。第二个活动中有什么?是否要在下一个活动中发送数据?没有,只打开一个空白活动。例如:如果单击“CA”,它将打开一个空白活动,然后只需创建一个新活动,如:class NewActivity extends activity{}