如何在对话和活动之间传递值?
我要求用户通过对话框输入:
package com.android.cancertrials;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class CustomDialog extends Dialog {
private String name;
// private ReadyListener readyListener;
public static EditText etName;
public String zip;
public CustomDialog(Context context, String name) {
super(context);
this.name = name;
// this.readyListener = readyListener;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mycustomdialog);
setTitle("Enter the Zip Code ");
Button buttonOK = (Button) findViewById(R.id.ok);
buttonOK.setOnClickListener(new OKListener());
etName = (EditText) findViewById(R.id.EditZip);
}
private class OKListener implements android.view.View.OnClickListener {
@Override
public void onClick(View v) {
// readyListener.ready(String.valueOf(etName.getText()));
CustomDialog.this.dismiss();
}
}
}
当用户点击“确定”时,如何将在文本框中输入的值传递回启动它的活动中的成员变量?