I’m trying to create an introduction to my program with a helpful dialog message system.
I don’t want to overload the user with too much text at once so I want to break up my dialog into parts.
Each part of course would have its own message.
I use a separate static class to handle message delivery and flow logic; and it’s working fine.
I also actually use 3 Dialogs.
One for the first message (since you can’t go back), one for the middle message and one for the final message (since you can’t go forward).
I’m able to call the middle message from the first message with no problem. I’m also able to return to the first message. But when I try to reshow the middle message from the middle message dialog the new dialog doesn’t appear.
Example:
Let’s say I have 4 messages, so the middle message will need to appear twice:
- First message appears: user clicks next
- Middle message appears: user clicks previous
- First message appears: user clicks next
- Middle message appears: user clicks next
- Middle message appears: user clicks next
- Final message appears
The problem is that I get no dialog on step 5.
I’m using onPrepareDialog to reinitialize the dialogs as they’re used. Right now it’s basically a clone of onCreateDialog where each case in the switch calls the builder method appropriate for that dialog.
This is the code for my middle dialog method. (The other 2 are about the same. You can guess what they look like from this.)
protected AlertDialog buildMiddleNoticeDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.setTitle(Notice.getTitle())
.setMessage(Notice.getMessage())
.setCancelable(false)
.setNegativeButton(resources.getString(R.string.notice_next_button),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
showDialog(Notice.next());
}
})
.setPositiveButton(resources.getString(R.string.notice_previous_button),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
showDialog(Notice.previous());
}
});
return builder.create();
}
I used a normal dialog with a TextSwitcher inside and two buttons to step forward or backward. The TextSwitcher simply changes the text and some animation are possible for text change. Try that!
The functionality of the two buttons simply depends on the position in my string array where all the messages are stored in ordered positions.
Thats my activity which is started with a dialog theme: http://saintfeintcity.org/projects/sfc/repository/entry/trunk/src/org/saintfeintcity/activities/TippsAndTricksActivity.java