为什么我不能删除一个项目? [英] Why can't I remove an item?

查看:206
本文介绍了为什么我不能删除一个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很沮丧,因为我今天一直在尝试这4个小时,我无法找到一个解决方案。出于某种原因,我的上长按监听不会被检测到,有时!

I am really frustrated because I have been trying this for 4 hours today, and I can't find a solution. For some reason, my on long click listener doesn't get detected sometimes!

 listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                                       int pos, long id) {

            Toast.makeText(MainActivity.this, "Long click", Toast.LENGTH_SHORT).show();

            contactArrayList.remove(pos);
            arrayAdapter.notifyDataSetChanged();


            return true;
        }
    }); 

这个简单的code只是从我的列表中删除一个项目,并使用适配器我的数组列表。但是,有时候,的onItemLongClickListener甚至不被调用,并致祝酒辞甚至不显示!我知道Android是检测它,因为我在我的日志得到这个消息时,我长按猫:

This simple code just removes an item from my list and my array list using an adapter. But, sometimes, the onItemLongClickListener doesn't even get called, and the toast doesn't even display!! I know that android is detecting it, because I get this message whenever I long click in my log cat:

/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP

那么,为什么它只是有时工作?是不是有什么毛病我code,或者这是一个问题与Android本身呢?如果是与Android有问题,我应该如何解决呢?

So why does it only work sometimes? Is there something wrong with my code, or is this a problem with android itself? If it is a problem with android, how can I fix it?

它的工作原理是第一次,但退出我的应用程序,旋转屏幕等之后,龙preSS停止得到检测。我一直停留在此为近8小时了,我真的,真的,真的需要你的帮助。

推荐答案

我得到一个类似的问题在我的长按一个列表项没有得到认可一个特殊情况。

I am getting a similar issue where my long Click on a list item doesn't get recognized for one particular case.

这是怎么回事,我当我的列表项文本视图包含一个可点击的链接。我可以单击超链接和Android重定向我到一个浏览器,但我的长按/单点击并不会在这种情况下得到认可整个项目选择,因此我Actionmode也不起作用。

It's happening for me when my list item text view contains a click-able hyperlink. I am able to click the hyperlink and android redirects me to a browser but my long click/ single click doesn't get recognized for the whole item selection in this case and hence my Actionmode also doesn't work.

我想通过下面的链接来解决它,希望它有助于

I am trying to solve it through the following links, hope it helps

<一个href=\"http://stackoverflow.com/questions/7959409/android-listview-doesnt-receive-onitemclick-for-textview-with-clickable-links\">link 1

<一个href=\"http://stackoverflow.com/questions/11610023/click-is-not-working-on-the-listitem-listview-android\">link 2

这篇关于为什么我不能删除一个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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