How To Show A Message " Registered Successfully"
I m showing a dialog box for 5000ms now I want to show a message 'Registered successfully' after that dialog box disappears. How can I do this? Thanks$Regards. Here is the code
Solution 1:
Instead of using a Dialogbox, you can use a Toast object. This can be configured to disappear after a certain time.
http://developer.android.com/guide/topics/ui/notifiers/toasts.html
Solution 2:
Solution 3:
Use following code
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
publicclassMainextendsActivity{
Buttonbtn=null;
ProgressDialogdialog=null;
intcounter=0;
Threadt=null;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);
setContentView(R.layout.myxml);
btn = (Button) findViewById(R.id.btn001);
btn.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View arg0) {
// TODO Auto-generated method stub// tv.setHint(tv.getHint());// while(counter<2){
t = newThread() {
publicvoidrun() {
// register();try {
// while(counter<2){
updateGallery(0);
Thread.sleep(5000);
updateGallery(2);
Thread.sleep(1000);
updateGallery(1);
// }
}catch(Exception ex){
ex.printStackTrace();
}
}
};
t.start();
}
// tv.setTextColor(getResources().getColor(R.color.DarkBlue));// }
});
// tv.setFreezesText(true);
}
@Overrideprotected Dialog onCreateDialog(int id) {
switch (id) {
case0: {
++counter;
dialog = newProgressDialog(this);
dialog.setMessage("Registering...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
}
}
return dialog;
}
publicvoidupdateGallery(int actionsToBePerformedOnScreen) {
Messagemsg=newMessage();
msg.what = actionsToBePerformedOnScreen;
galleryListHandler.sendMessage(msg);
}
publicHandlergalleryListHandler=newHandler() {
@OverridepublicvoidhandleMessage(Message msg) {
switch (msg.what) {
case0:
showDialog(0);
break;
case1:
// clear all images in the list
removeDialog(0);
break;
case2:
dialog.setMessage("Registered successfully");
break;
}
};
};
}
Post a Comment for "How To Show A Message " Registered Successfully""