我想存储输入EditText
并在另一个对话框中显示它。我怎样才能做到这一点?
因此,我在其中一个中编写并保存了 2 个活动,在另一个中我加载它。
public class SaveDialog extends Dialog implements View.OnClickListener{
private MapEditorView mapEditorView;
private Context context;
private Button ok;
private EditText editTextMap;
private boolean exist;
public SaveDialog(Context context, MapEditorView mapEditorView) {
super(context);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.context = context;
this.mapEditorView = mapEditorView;
setContentView(R.layout.dialog_mapeditor_save);
ok = (Button) findViewById(R.id.Button_save_map);
ok.setOnClickListener(this);
exist = true;
}
public void onClick(View v) {
if (v.getId() == ok.getId()) {
if(exist){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("Are You sure?");
// set dialog message
alertDialogBuilder
.setMessage("Current map Name will be overwritten!")
.setCancelable(false)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
mapEditorView.getEditMapRenderer().reNameMap(
String.valueOf(editTextMap.getText().toString()));
dismiss();
}
})
.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
else{
mapEditorView.getEditMapRenderer().reNameMap(String.valueOf(editTextMap.getText().toString()));
this.dismiss();
}
}
}
public void setExist(boolean exist) {
this.exist = exist;
}
}