/ / How to write this kind Toast displayed when the time is superimposed ah, solution:
package com.map.tools;
import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;
public class ToastShow {
private Context context;
private Toast toast = null;
public ToastShow (Context context) {
this.context = context;
}
public void toastShow (String text) {
if (toast == null) {
toast = Toast.makeText (context, text, Toast.LENGTH_SHORT);
toast.setGravity (Gravity.CENTER, toast.getXOffset () / 2,
Location
toast.getYOffset () / 2) ;/ / set display} Else {
toast.setText (text);
}
toast.show ();
}
}
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / Calls the code
if (b) {
Intent intent = new Intent (getApplication (), Home.class);
intent.putExtra ("username", name);
startActivity (intent);
} Else {
/ *
* Toast msg = Toast.makeText (Main.this,
* "User name or password is incorrect, please re-enter!", Toast.LENGTH_LONG);
* Msg.setGravity (Gravity.CENTER, msg.getXOffset () / 2,
* Msg.getYOffset () / 2); msg.show ();
* /
ToastShow toast = new ToastShow (getApplication ());
toast.toastShow ("user name or password is incorrect, please re-enter!");
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
No comments:
Post a Comment