-1
我有一個AlertDialog,在它我有一個EditText和兩個典型的按鈕([取消],[確定])AlertDialog關閉通過攔截奇東銳騰的EditText
It's正常工作,但我需要截取的奇東銳騰Edittext,然後我將必須關閉AlertDielog。
public static void Dialogo_Observaciones(Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Observaciones");
builder.setMessage("Ingrese las observaciones");
final EditText input = new EditText(context);
input.setInputType(InputType.TYPE_CLASS_TEXT);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId ==6){
//HERE I must close the AlertDialog and others things
}
return false;
}
});
builder.setView(input);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String Valor = input.getText().toString();
if (Valor.equals("") ==false){
Variables.Observaciones = Variables.Observaciones + " " + Valor.trim();
Variables.Observaciones = Variables.Observaciones.trim();
dialog.cancel();
}else{
dialog.cancel();
}
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
});
builder.show();
}
在此先感謝。
因爲它不起作用 – AAP 2012-08-03 18:33:42
是的,我確定。它工作正常,我測試它 – AAP 2012-08-03 18:49:59