Tushar Vengurlekar
Tushar Vengurlekar

Reputation: 7679

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 help. I don't want to show a progress bar. Can i disable the 2nd click or any other way to handle this problem?

Upvotes: 1

Views: 1646

Answers (4)

2red13
2red13

Reputation: 11227

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

Upvotes: 0

Gyan
Gyan

Reputation: 12410

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.

Upvotes: 1

Hades
Hades

Reputation: 3936

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

Upvotes: 0

Ben Williams
Ben Williams

Reputation: 6167

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.

Upvotes: 2

Related Questions