views:

1126

answers:

4

I'm facing the same head-scratching moment similar to what this person (from Jan 2008) experienced when I realize that there is no cancel button in Android's progress dialog or spinners. It is now July 2009 and I've just installed the cupcake version of Android. Has this thing changed ? If not, are you adding a cancel button into the dialogs and how do you do it ?

+5  A: 

I'm no Android user or developer, but I think the answer given in the linked-to thread is pretty decent: there's a hardware "back" key on all Android devices. Users are supposed to know to press Back to back out of whatever activity they're currently in.

Thus, the UI designers feel it's unnecessary to include a GUI back/cancel button. This could be viewed as the UI application of the DRY principle; if there's already one way of doing something, that's enough.

unwind
Historically in UI it's generally been considered better to provide multiple redundant ways to achieving the same task. Interesting approach if that's the reason they did it.
Alistair Knock
The BACK button in my opinion is synonymous with the browser back button. It is not intuitive to me (and to even the techies in my office) that pressing back dismisses the dialog.
Jacques René Mesrine
Then you just have to wait for the dialog to close, or select the already selected item in the spinner. Generally backing out of a progress dialog doesn't cancel the action because the app should be doing the long running process in a thread anyways. Unless they're looking for the dialog to be closed, the process is going to complete at some point regardless.
Andrew Burgess
If the programmer thinks a cancel button would be useful they can easily add it. There's no need to have it by default as it isn't needed in all situations.
AshtonBRSC
But the problem is that back does *NOT* mean cancel. For instance, if you are using a PreferencesActivity with Checkbox preferences, the preference change is committed the instant that you toggle the state of the button. Thus pressing back after you have changed settings does not cancel; you are left with same state.See http://www.mail-archive.com/[email protected]/msg56981.html for more on this.
I82Much
+1  A: 

The hardware key is the answer here. I'd be careful about generalising the DRY principle to UIs. There are plenty of cases where you need to hammer, hammer, hammer the same point to the user repeatedly via headings, body text, colours and images.

Users dont "read" UIs the way you read a novel. They scan read.

Harry
+1  A: 

I can't speak for other apps, but in mine anything that might cause the UI thread to wait is executed in a seperate thread. The most I'll do is show a small progress spinner in the titlebar to let the user know something is going on in the background.

Will
A: 

not sure about the whole cancel button...i've heard reports of the onCancel() method not firing properly. my solution just consists of making a normal button on the dialog with a call to return whenever the button is pressed.

private void createCancelProgressDialog(String title, String message, String buttonText)
{
    cancelDialog = new ProgressDialog(this);
    cancelDialog.setTitle(title);
    cancelDialog.setMessage(message);
    cancelDialog.setButton(buttonText, new DialogInterface.OnClickListener() 
    {
        public void onClick(DialogInterface dialog, int which) 
        {
            // Use either finish() or return() to either close the activity or just the dialog
            return;
        }
    });
    cancelDialog.show();
}

then just use a simple call method from elsewhere in your activity

createCancelProgressDialog("Loading", "Please wait while activity is loading", "Cancel");

rather simple solution, but it does the trick ;) also just to note that cancelDialog is an activity wipe variable, if you dont need to call it from elsewhere, then you should be able to get away with just limiting the scope of the variable to that method.

chich