English 中文(简体)
在关闭警报组织之后,希望收回任何价值。
原标题:want to get back any value after closing Alert Dialog

我将Dialog用作Login。 因此,在关闭该方言之后,方言显示的任何价值都丢失。 如何收回这一价值? 我的法典如下:

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);
}

根据我的法典, PIN和FPIN的数值被丢失。 I wanna在PinCode之外使用这些价值。 如何获得?

实际上,我把这一职能称为已改变的活动。 如果记录通过,用户可以查阅另一个表格。 但是,在点击Okohton之前,所有游艇都已经在打上了变换的活动。 我的表态活动如下:

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 );    
            }
        });

是否有任何类型的糖尿病适合Login? 如何解决?

问题回答

Edit:在你的负面/积极性 but子中,你必须从周围类别中指定一个职能,确定这两个参数,其数值载于

例如:

private String mStrPin;
private float mFPin;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

............

    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {   
            String strPin = "1234";
            float fPin = 1.234f;
            public void onClick(DialogInterface dialog, int which) {
                loggedIn(strPin, fPin);
            }
    }

............

}
private void loggedIn(String strPin, float fPin) {
    mStrPin = strPin;
    mFPin = fPin;
}

简化实例:

public interface TextListener {
    void onPositiveResult(CharSequence text);
}

public static AlertDialog getTextDialog(Context ctx,
        final TextListener listener) {
    View view = LayoutInflater.from(ctx).inflate(R.layout.dialog, null);
    final TextView tv = (TextView) view.findViewById(R.id.tv);
    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    builder.setView(view);
    //
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            listener.onPositiveResult(tv.getText());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    return builder.create();
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签