我有吐司的问题。当用户成功登录数据库时,如何使 toast 消失。
用户登录失败的代码如下:
类 BuatLogin 扩展 AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Login_layout.this);
pDialog.setMessage("Login_layout Progress...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... args) {
String usr = user.getText().toString();
String pwd = pass.getText().toString();
Log.d("1 "+usr, pwd);
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("usr", usr));
params.add(new BasicNameValuePair("pwd", pwd));
Log.d("2 "+usr, pwd);
Log.d(usr,url_create_login);
// getting JSON Object
JSONObject json = jsonParser.makeHttpRequest(url_create_login,
"POST", params);
Log.d("Buat Respond", json.toString());
try {
int sukses = json.getInt(TAG_SUKSES);
if (sukses == 1) {
String nim=json.getString(TAG_NIM);
String jrs=json.getString(TAG_JRS);
Log.d(TAG_NIM,nim);
// sukses login
Intent i = new Intent(getApplicationContext(), Mhs_main_layout.class);
i.putExtra(TAG_NIM, nim);
i.putExtra(TAG_JRS,jrs);
startActivity(i);
finish();
} else if(sukses == 2) {
String nip=json.getString(TAG_NIP);
Log.d(TAG_NIP,nip);
Intent i = new Intent(getApplicationContext(), Admin_main_layout.class);
i.putExtra(TAG_NIP, nip);
startActivity(i);
finish();
}else if(sukses == 3){
setResult(100);
//toas(100);
//finish();
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
//Respon dari upadte buku class
protected void onPostExecute(String file_url) {
pDialog.dismiss();
int resultCode = 100;
if (resultCode != 100);
{
Toast.makeText(Login_layout.this, "Nip/Nim Atau Password TIdak Sesuai Silahkan Coba Lagi ", Toast.LENGTH_LONG).show();
}
}
}
但是即使用户成功登录并且日志猫上没有错误,吐司也会不断出现。我该怎么做才能让它消失?