Android Implementation Login dialog box

Source: Internet
Author: User

Today introduces an implementation of an Android login dialog box.
Dialog.xml for setting Dialogview

Activity

packagecom.study.android;

importandroid.app.Activity;

Importandroid.app.AlertDialog;

Importandroid.app.ProgressDialog;

Importandroid.content.DialogInterface;

Importandroid.os.Bundle;

Importandroid.view.LayoutInflater;

Importandroid.view.View;

Publicclass Android_dialogactivity extends Activity {

/** called when the activity is firstcreated. */

ProgressDialog P_dialog;

@Override

public void OnCreate (bundlesavedinstancestate) {

Super.oncreate (savedinstancestate);

Setcontentview (R.layout.main);

Alertdialog dialog = Newalertdialog.builder (

Android_dialogactivity.this)

. Settitle ("Login Prompt")

. Setmessage ("Login")

. Setpositivebutton ("OK", new Dialoginterface.onclicklistener () {

@Override

Public Voidonclick (Dialoginterface dialog, int which) {

TODO auto-generated Method Stub

Layoutinflater Factory =layoutinflater

. from (Android_dialogactivity.this);

Final View Dialogview =factory.inflate (

R.layout.dialog, NULL);

Alertdialog dlg = Newalertdialog.builder (

Android_dialogactivity.this)

. Settitle ("Login Box")

. Setview (Dialogview)

. Setpositivebutton ("OK",

Newdialoginterface.onclicklistener () {

@Override

public void OnClick (

Dialoginterface Dialog,

int which) {

TODO auto-generated method

Stub

P_dialog = ProgressDialog

. Show (Android_dialogactivity.this,

"Please Wait",

"Signing in for you ...",

true);

Newthread () {

Publicvoid Run () {

try{

Sleep (3000);

}catch (Exception e) {

}finally {

P_dialog.dismiss ();

}

}

}.start ();

}

})

. Setnegativebutton ("Cancel",

Newdialoginterface.onclicklistener () {

@Override

public void OnClick (

Dialoginterface Dialog,

int which) {

Todoauto-generated method

Stub

Android_dialogactivity.this

. Finish ();

}

}). Create ();

Dlg.show ();

}

})

. Setnegativebutton ("Exit", new Dialoginterface.onclicklistener () {

@Override

Publicvoid OnClick (dialoginterface dialog, int which) {

TODO auto-generated Method Stub

Android_DialogActivity.this.finish ();

}

}). Create ();

Dialog.show ();

}

}

Some of the code is taken from the it online education platform Wheat Academy , as noted here.

Android Implementation Login dialog box

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.