今天热门
热点:

关于ListView的问题,ListView问题..


我在一个布局里面添加了一个ListView。结果出现问题老。
LayoutInflater inflate =(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
TableLayout tb = (TableLayout)inflate.inflate(R.layout.selectcontact, null);
        
        tb.addView(listview);
        setContentView(tb);





<?xml version="1.0" encoding="utf-8"?>
<TableLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <TableRow>
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="选择:"></TextView>
<Button android:text="全选" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="取消选择" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</TableRow>
<TableRow>
<TextView android:text="选择" android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<TextView android:text="姓名" android:id="@+id/TextView03" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<TextView android:text="电话" android:id="@+id/TextView04" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</TableRow>
</TableLayout>



其中R.layout.selectcontac 是我自定义的一个布局

问题是我做如上处理的话。。。导致我listview的adapter的getView()方法被多次调用 导致程序运行不正常。。请问 这个问题如何解决呢。。

解决方案

自己问题自己解决,呵呵。

楼主自学成才 !要向你学习。

 listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
实在ListView中加单选框的,直接调用系统默认的样式

我觉得自己重写了Adapter,就不要再去调用系统的自带模式,不小心就出错,

www.zrccd.nettrue/topics/20180204/188782.htmlTechArticle关于ListView的问题,ListView问题.. 我在一个布局里面添加了一个ListView。结果出现问题老。 LayoutInflaterinflate=(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); TableLayouttb=(TableLayout)i...

相关文章

    暂无相关文章

用户评论

大家都在看