我尝试EditText
在 a 中使用 a Dialog
。我使用来自 developer.android.com ( http://developer.android.com/guide/topics/ui/dialogs.html )的示例。现在我想在Value
按下 时获得 EditText 的positive Button
。
我的代码
public Dialog onCreateDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(main_list.this);
// Get the layout inflater
final LayoutInflater inflater = main_list.this.getLayoutInflater();
builder.setView(inflater.inflate(R.layout.serie_add, null))
// Add action buttons
.setPositiveButton(R.string.search, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
View promptsView = inflater.inflate(R.layout.serie_add, null);
final EditText userInput = (EditText) promptsView
.findViewById(R.id.series);
Intent intent = new Intent();
intent.setClass(main_list.this, add_series.class);
intent.putExtra("name", userInput.getText());
startActivity(intent);
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
return builder.create();
}