Login in the form of a dialog box

Source: Internet
Author: User

These two days have been written landing, but also to be able to automatically login, really let small white I feel headache ah. But the code is a line to write, refueling. Here to record the way before, pop-up dialog box, but so write automatic landing when not very good to write, so now to approximate. But before writing the dialog box also took the time to turn Kung Fu, who let is small white it. Or record, leave a reference.

  

Players click on the item to log in, determine when to log in, and whether the login is correct
public void Teamdialog () {

Builder Alertdialog = new Alertdialog.builder (mainactivity.this);
if (flag = = 1) {
Alertdialog.settitle ("User login:");
Alertdialog.seticon (R.drawable.btn_star_team);

Alertdialog.setpositivebutton ("Landing",
New Dialoginterface.onclicklistener () {

@Override
public void OnClick (Dialoginterface dialog, int which) {
PostData ();

}
});
} else if (flag = = 0) {
Alertdialog.settitle ("Captain Login:");
Alertdialog.seticon (R.drawable.btn_star_captain);

Alertdialog.setpositivebutton ("Login",
New Dialoginterface.onclicklistener () {

@Override
public void OnClick (Dialoginterface dialog, int which) {
Decide whether to pass, then jump out of the privileges page

}
});
}
Alertdialog.setview (Dialogview);
Alertdialog.setnegativebutton ("Cancel",
New Dialoginterface.onclicklistener () {

@Override
Public void OnClick (dialoginterface dialog, int which) {
Dialog.dismiss ();
}
});
alertdialog.create ();
uiutils.removeparent (dialogview);
alertdialog.show ();
}

/**
* Events that start when the user clicks the login button
*/
Public void Teamlogin () {

Usernunbervalue = User_number.gettext (). toString ();
Userpassvalue = User_password.gettext (). toString ();

loginnetwork network = new Loginnetwork ();
hashmap<string, string> map = new hashmap<string, string> ();
if (Usernunbervalue.equals ("") | | Userpassvalue.equals ("")) {
result = 0;
}else{
map.put ("number", usernunbervalue);
map.put ("password", userpassvalue);
result = Network.load (1,map);
}
}
/**
* Transmit Data server Interface
*/
Public void PostData () {
threadmanager.getinstance (). Createlongpool (). Execute (new Runnable () {

@Override
public void Run () {

Teamlogin ();
Uiutils.runonuithread (New Runnable () {

@Override
Public void Run () {
if (Result! = 0) {
Toast.maketext (Uiutils.getcontext (), "Login successful!" ", Toast.length_long). Show ();
//// pass a parameter to Me_fragment's detail page to show the current user's information
Bundle data = new bundle ();
data.putstring ("tag", usernunbervalue);
mefragment = new Mefragment ();
mefragment.setarguments (data);

}else{
Toast.maketext (Uiutils.getcontext (), "¥_¥ Login failed, please login again!" ", Toast.length_long). Show ();
}

}
});
}
});
}

Login in the form of a 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.