Android的 - 的setSelected在OnItemClick中的ListView [英] Android - setSelected in OnItemClick in ListView

查看:90
本文介绍了Android的 - 的setSelected在OnItemClick中的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置的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

如果您的解决方案是不是在那里(我想这是第一个),我们将需要更多的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.

希望这有助于一点。

这篇关于Android的 - 的setSelected在OnItemClick中的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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