私はログインページを持っていますので、私はSharedPreferences
を使用しています。私は価値を保存しようとしています。 値がなければ、それは私がログインページでこれを与えていることのために別のActivity
に行くべきではありません。条件がsharedpreferencesで動作していません。
if((spf != null) && (spv !=null) && (et1v != null) && (et2v != null) && (et3v != null) &&
(sp != null) && (et1 != null) && (et2 != null) && (et3 != null)){
finish();
Intent i = new Intent(Login.this,Welcome.class);
startActivity(i);
}
else{
btn1.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (sp.getSelectedItem().toString().length() > 0 &&
et1.getText().toString().length() > 0 &&
et2.getText().toString().length() > 0 &&
et3.getText().toString().length() > 0)
{
SharedPreferences spf = getSharedPreferences("newprfs", Context.MODE_PRIVATE);
SharedPreferences.Editor spe = spf.edit();
spe.putString("uname",sp.getSelectedItem().toString());
spe.putString("password",et1.getText().toString());
spe.putString("mobile",et2.getText().toString());
spe.putString("dept",et3.getText().toString());
spe.commit();
finish();
Intent i = new Intent(Login.this,Welcome.class);
startActivity(i);
}
}
}
);
}
この私のウェルカムページ
SharedPreferences spf = getSharedPreferences("newprfs", Context.MODE_PRIVATE);
SharedPreferences.Editor spe = spf.edit();
String spv = spf.getString("uname","");
String et1v = spf.getString("password","");
String et2v = spf.getString("mobile","");
String et3v = spf.getString("dept","");
if((spe != null) && (spv !=null) && (et1v != null) && (et2v != null) && (et3v != null) &&
(sp != null) && (et1 != null) && (et2 != null) && (et3 != null)){
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
Intent i = new Intent(Welcome.this,MainActivity.class);
startActivity(i);
Welcome.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
else{
Intent i = new Intent(Welcome.this,Login.class);
startActivity(i);
Welcome.this.finish();
}
}
問題は、それは常に空白を示すということです画面。私はLog.d("@@@@@@@@@@@@@@[email protected]@@@@@@@@@@@@@@@")
でチェックしようとしました。 私は常にログインページでの読み込みとif condition
が動作していないことを認識しました。いずれか1つは私に何を間違って提案することができますif Condition..
?
更新 ここではそのない共有環境設定を通報します..しかし、ここではその条件を通報します...
I If Condition
値を入力せずに値ならば、それはまた、次へ移動...とはなりません既に定義済みです。次のページに移動する必要があります...
したがって、次のページに移動して次のページに移動します。同じ条件を指定して再度同じログインページに移動します。だから、それはシングルページにとどまり、空白の画面が表示されています。
..私はまた、HashMapを使用することをお勧めこの問題に直面していました...しかし、これはあなたのケースのために働く、この
spv.contains("uname")
の代わりに、(spv !=null)
またはspv.equals("")
を試してみてくださいcontains(String Key)
で試してみる必要があります上記のif()条件の上に –
私はすでにその問題を定義していません。ここで条件の問題はここで私はトーストでチェックしたログインの詳細を取得できますが、その状態の問題は... – ravi
私は 'ログインページのボタンですべての詳細を入力した後に動作しません...私の緊急に私に答えてください。 – ravi