开发者

Avoid Multiple Clicks

I am having an app which contains number of list views. That means One listview opens another listiview on click of an item from first listview. Then it opens third one, on click of item from second list and so on. Now problem here is that the listview takes some time to populate data, giving user a feel that the click is not acknowledged and user presses it again. Due to this the first click opens the 2nd list and 2nd click opens third list, which is not desired. How can I take care of this. I tried using listview.setEnabled(false) but that doesn't he开发者_如何转开发lp. I don't want to show a progress bar. Can i disable the 2nd click or any other way to handle this problem?


Set a global boolean $bBeenClicked, make it true on the first click and check it on the second; set it back to false when the list has finished loading.


You should look into enhancing the performance of your ListViews. Unless they need to access something over the internet or have some other similar constraint, they shouldn't take so long to load. A good ListView should only load what can be shown on the screen and then load more as needed when the user scrolls down. There are a few techniques you can use like making sure you reuse the convertView aswell. I would recommend that you watch this video. It goes into the best ways to implement ListView so that it performs well.


You could add haptic feedback for when the user clicks on a listview item to tell the user that it was clicked.

How to enable haptic feedback on button view


You shoudl load the new List in a PpgressDialog:

public static void open_new_list(int level)
    {

        verlauf = ProgressDialog.show(ctx, "Wait...", "...load new List",true,false);
        new Thread(){
             @Override
            public void run(){
                Looper.prepare();
                  //load the new Listview
                  //display via runnable
                 }
                verlauf.dismiss();  
             }
        }.start();
    }

edit: Without Progressbar you might remove the adapter after klicking, then the user isn't able to klick twice

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜