Android的 - 的setSelected在OnItemClick中的ListViewsetSelected、Android、ListView、OnItemClick

2023-09-04 12:48:24 作者:不争也不会让

我想设置的ListView在OnItemClick事件选择的项目,它只是不会离开项目中选择。我究竟做错了什么?

I am trying to set item selected in OnItemClick event in ListView and it just wouldn't leave item selected. What am I doing wrong?

lView.setOnItemClickListener(new OnItemClickListener()
   {
    @Override
    public void onItemClick(@SuppressWarnings("rawtypes") AdapterView parent, View clickedview, int position, long id)
    {
     clickedview.setSelected(true); 
        mItemsAdapter.select(position);
    }
   }); 

几件事情: 1.我想实现在多个列表视图中选择。 2.我不能从ListActivity延伸,因为活动从BaseActivity自定义类扩展了。 3. mItemsAdapter是一个自定义ItemsAdapter适配器,扩展了BaseAdapter。 4.我不需要在那里的复选框,只是为了能够看到选择的行是好的。 5. ItemsAdapter覆盖getView(),并将该行的布局由充气的xml

few things: 1. I am trying to implement Multiple Select on the list View. 2. I cannot extend from ListActivity because Activity extends from BaseActivity custom class already. 3. mItemsAdapter is a custom ItemsAdapter adapter that extends BaseAdapter. 4. I don't need a checkbox in there, just to be able to see the row selected is fine. 5. ItemsAdapter overrides getView() and sets the layout of the row by inflating xml

推荐答案

目前,我没有太多的时间。因此,我会再看看后面这一天。 反正看看我的previous的问题,我挣扎着相同的:

I currently don't have much time. So I'll take a look again later this day. Anyway take a look at my previous questions, I was struggling with the same:

更改ListView的背景 - strage行为

可点击的ListView

如果您的解决方案是不是在那里(我想这是第一个),我们将需要更多的code,以帮助你。

In case the solution for you is not in there (I think it's in the first one) we will need more code, in order to help you.

希望这有助于一点。