安卓:禁用的ListView一旦点击? [英] Android: Disable ListView once clicked?

查看:83
本文介绍了安卓:禁用的ListView一旦点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图,当在ListView单击的项目,我保存了详细的SQLite数据库使用AyscTask这是从ListView的onitemclicklistener调用。当用户点击任意多个项目应用程序崩溃的应用程序尝试peculier的方式来访问数据库。这种情况发生在用户足够快的点击列表视图多个项目之前加载警报显示出来。

I have a list view and when item in the listview clicked, I save the detail to sqlite db using AyscTask which is called from listview's onitemclicklistener. When user randomly clicks many items application crashes as app try to access db in peculier way. This happens when the user is fast enough to click multiple items in the listview before the loading alert shows up.

我如何prevent这个?我试图禁用ListView的onitemclick方法中的列表视图,但它没有工作过。

How can I prevent this?? I tried to disable listview inside the listview's onitemclick method but it didn't work too.

我的code

//setting up the listview
        ListView lv = (ListView) findViewById(android.R.id.list);
        setListAdapter(new TypeArrayAdapter(TypeSelectActivity.this, R.layout.row_type, typeList));

        lv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {

                sectionid = Integer.parseInt(LocationWebService.incidentTypeSectionId
                        .get(arg2));
                incidentid1 = Integer
                .parseInt(LocationWebService.incidentTypeId
                        .get(arg2));

                LocationWebService.IncidentTypeID = incidentid1;
                LocationWebService.sectionID = sectionid;
                new DBTasks().execute(arg2);
                TextView tv=(TextView)arg1.findViewById(R.id.label_type);
                TypeString=tv.getText().toString();
                Log.v("TypeSelect", TypeString);

            }
        });

感谢您的时间提前。

Thanks for your time in advance.

推荐答案

尝试使用禁用AsnykTask列表 - > preExecute ,使列表中的 PostExecute ..

try using disable the list in AsnykTask -> PreExecute and enabling the list in PostExecute..

这篇关于安卓:禁用的ListView一旦点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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