android ListView的点击事件跳转到另一个activity怎么写
privateString[]data={"第一个活动贴","第二个活动贴","第三个活动贴","第四个活动贴","第五个活动贴","第六个活动贴","第七个活动贴","...
private String[]data={"第一个活动贴","第二个活动贴","第三个活动贴","第四个活动贴","第五个活动贴","第六个活动贴","第七个活动贴","第八个活动贴","第九个活动贴","第十个活动贴","第十一个活动贴","第十二个活动贴","第十三个活动贴","第十四个活动贴","第十五个活动贴"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.one);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(
this,android.R.layout.simple_list_item_1,data);
ListView listView=(ListView) findViewById(R.id.listView);
listView.setAdapter(adapter);
接下来怎么写ListView的点击事件让它跳转到另一个activity 展开
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.one);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(
this,android.R.layout.simple_list_item_1,data);
ListView listView=(ListView) findViewById(R.id.listView);
listView.setAdapter(adapter);
接下来怎么写ListView的点击事件让它跳转到另一个activity 展开
2个回答
展开全部
写一个item监听方法,在方法里写跳转。
追问
能不能具体点啊,item监听方法怎么写呢,一直写不对
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent=new Intent(MainActivity.this,TargetActivity.class);
startActivity(intent);
}
});
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询