无法将listiview的setchoice模式设置为多选模式

时间:2014-01-12 08:05:50

标签: android listview android-listview

我无法将listview的选择模式设置为CHOICE_MODE_MULTIPLE。

我已将选择模式设置为多个,如下所示:

lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

但由于我在listview的行中使用自定义布局,这就是为什么我可能面临这个问题。

ListViewHomeAdapter adapter = new ListViewHomeAdapter(this, R.layout.listview_item_row,listViewHomeData);

有人有解决方案吗?

这里是ListViewHomeAdapter.java的代码

公共类ListViewHomeAdapter扩展了ArrayAdapter {

Context context;
int layoutResourceId;
ListViewHome data[] = null;

public ListViewHomeAdapter(Context context, int layoutResourceId, ListViewHome[] data)
{
    super(context, layoutResourceId, data);

    this.context = context;
    this.layoutResourceId = layoutResourceId;
    this.data = data;       
}

@Override

public View getView(int position, View convertView, ViewGroup parent)
{
    View row = convertView;
    ListViewHomeHolder holder = null;

    if(row == null)
    {
        LayoutInflater inflater = ((Activity)context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);
        holder = new ListViewHomeHolder();

        holder.DocName = (TextView) row.findViewById(R.id.txtTitle);
        holder.CreationDate = (TextView) row.findViewById(R.id.txtDate);

        row.setTag(holder);
        row.setMinimumHeight(20);
    }
    else
    {
        holder = (ListViewHomeHolder) row.getTag();
    }

    ListViewHome listviewhome = data[position];
    holder.DocName.setText(listviewhome.DocName);
    holder.CreationDate.setText(listviewhome.CreationDate);

    return row;
}

static class ListViewHomeHolder
{
    TextView DocName;
    TextView CreationDate;
}

}

0 个答案:

没有答案