android列表视图可点击问题 [英] android list view clickable problem

查看:32
本文介绍了android列表视图可点击问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个定制的列表.每行包含一个图像和两行文字,一个在另一个下方.我想在单击任何列表项时打开一个新活动.但我无法这样做,即使在实施了 setOnItemClickListener() 之后.如果我错了,请纠正我.下面是列表的代码.PS:这是一个正常的活动,不是列表活动.

i have this customized list. each row contains an image and two lines of text one below the other. i want to open a new activity when any list item is clicked. but i am not able to do so, even after implementing the setOnItemClickListener(). please correct me if i am wrong. the below is the code for the list. PS: This is an normal activity and not list activity.

l1.setAdapter(new EfficientAdapter(this,eventTitleArray,eventDateArray,eventImageLinkArray));
   //l1 = getListView();
   l1.setClickable(true);
   l1.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1,
      int position, long arg3) {
     Intent intent = new Intent(MainActivity.this, DisplayActivity.class);
     Bundle b = new Bundle();
     b.putString("event", eventTitleArray[position]);
     intent.putExtras(bundle);
     startActivity(intent);

     Toast.makeText(getApplicationContext(), "Opening detailed view for:"+eventTitleArray[position], Toast.LENGTH_SHORT).show();


    }
   });

推荐答案

请查看行布局是否有可聚焦的项目.如果 ListView 项包含可聚焦的子项,则不会触发 Listview 处理程序.

Please have a look whether the row layout has any items which are focusable. If an ListView Item contains focusable children, the Listview Handler will not be fired.

这篇关于android列表视图可点击问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆