アラート ダイアログをログインとして使用します。したがって、このダイアログを閉じると、ダイアログ show() で割り当てられた値はすべて失われます。この値を取り戻すには?私のコードは以下です
private void accessPinCode()
{
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.dialog_login, null);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Title");
alert.setMessage("Enter Pin :");
alert.setView(textEntryView);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
EditText mUserText;
mUserText = (EditText) textEntryView.findViewById(R.id.txt_password);
//String strPinCode = mUserText.getText().toString();
Log.d( TAG, "Pin Value 1 : " + mUserText.getText().toString());
strPIN = mUserText.getText().toString();
Log.d( TAG, "strPIN inside accessPinCode : " + strPIN);
fPIN= checkPINCode();
Log.d( TAG, "fPass : " + fPIN);
return;
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
return;
}
});
alert.show();
Log.d( TAG, "strPIN outside Alert Show : " + strPIN);
}
私のコードによると、strPIN と FPIN の値が失われています。これらの値を accessPinCode 関数の外で使用したい。取得する方法?
実際、私はこの関数を tabchanged イベントで呼び出します。ログインに成功すると、ユーザーは別のタブにアクセスできます。ただし、AlertDialog の [OK] ボタンをクリックする前に、すべてがタブ変更イベントで既に機能しています。以下のような私のタブイベント
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
if (tabId.equals("index"))
{
tabHost.setCurrentTab(1);
accessPinCode();
}
Log.d( TAG, "tabId : "+ tabId );
}
});
ログインに適したダイアログの種類はありますか? の解き方?