我正在使用活动。当我点击我的 EditText 时,会出现一个对话框,如下所示: http ://techblogon.com/wp-content/uploads/2013/03/alert-dialog-with-edittext-in-android.png
在我的第一个活动中,如何现在将字符串(我的姓名)从对话框传递到 EditText?这是我的代码:
public class Main extends Activity implements OnItemSelectedListener {
EditText inputName;
Button btnName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
inputName = (EditText) findViewById(R.id.add_name);
inputName.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Dialog();
}
});
// Add Healthcare Button Click event
btnName.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
final String nameD = inputDoctorName.getText().toString();
Log.d("TEST","SUCCESS");
}
});
}
protected void Dialog()
{
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.layout_dialogbox);
dialog.setTitle("Description de la note");
Button ok = (Button)dialog.findViewById(R.id.btnOK);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
}
你能帮我吗 ?