如何在列表视图android的整行可点击 [英] how to make full row clickable in listview android

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

问题描述

我有内容在第一排假设Android,黑莓在第三行第二行和iphone一个ListView等等,现在我想使ListView的整排的点击,但是当我点击上面的ListView行的内容,那么它仅执行点击事件,但我想,如果我连续点击任何地方,然后点击动作要performed.My code制作列表视图点击下面的是:

 公共无效的onCreate(捆绑savedInstanceState)
{
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.listartistspacedetailview);    setListAdapter(新ArrayAdapter(这一点,R.layout.listitem_layout,R.id.barrio,keywordxmlparsing.array_artistname));}
@覆盖
保护无效onListItemClick(ListView中升,视图V,INT位置,长thisID)
{
    意图I =新意图(Artistspacedetailview.this,Loadingimagetab.class);
    startActivity(ⅰ);
}

和xml文件中ListView的标签是:

 < ListView控件
    机器人:可点击=真
    机器人:layout_marginLeft =10dip
    机器人:layout_marginRight =10dip
    机器人:ID =@ + ID /安卓名单
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_weight =1
    机器人:layout_below =@ ID / horizo​​ntolline
    机器人:cacheColorHint =#00000000
    机器人:drawSelectorOnTop =FALSE/>


解决方案

我知道这个问题是旧的,但它是第一次打,我在谷歌的时候我一直在寻找这个问题。

这是我的解决方案。

 < ListView控件
    机器人:ID =@ + ID / XXXXXX
    机器人:layout_width =FILL_PARENT//从包装内容变更
    机器人:layout_height =FILL_PARENT//从包装内容变更
    机器人:可点击=真正的> //这个建议中的其他主题
< /&的ListView GT;

I have a ListView with contents as suppose android in 1st row,blackberry in second row and iphone in 3rd row so on now I want to make ListView's whole row clickable but when I click above content of listview row then it performs only click event but I want if I click any where in a row then a click action should be performed.My code for making listview clickable is below:

public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listartistspacedetailview);

    setListAdapter(new ArrayAdapter(this,R.layout.listitem_layout,R.id.barrio, keywordxmlparsing.array_artistname));

}   
@Override
protected void onListItemClick(ListView l, View v, int position, long thisID)
{
    Intent i = new Intent(Artistspacedetailview.this, Loadingimagetab.class);
    startActivity(i);   
}

and ListView tag in xml file is :

<ListView
    android:clickable="true"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="10dip"
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:layout_below="@id/horizontolline"
    android:cacheColorHint="#00000000"
    android:drawSelectorOnTop="false" />

解决方案

I know this question is old, but it was the first hit for me in google when I was looking for this problem.

This is my solution.

<ListView
    android:id="@+id/XXXXXX"
    android:layout_width="fill_parent"   // Changed from wrap content
    android:layout_height="fill_parent"  // Changed from wrap content
    android:clickable="true" >           // This was suggested in other topics
</ListView>

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

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