【发布时间】:2014-01-15 17:09:46
【问题描述】:
你好,我有一个活动,我从中调用了一个对话框。当对话框出现时,我在edittext中写了一些东西,然后单击保存按钮...问题是在关闭对话框并返回活动后,键盘仍然存在¡¡
我已经尝试过这样的解决方案:
a) 在布局(xml)中:
android:imeOptions="actionDone"
b) 在布局(xml)中:
android:focusable="true"
android:focusableInTouchMode="true"
c) 在清单中:
android:windowSoftInputMode="stateHidden"
但这不起作用...关闭对话框后键盘不会消失。
请提供一些线索来解决我的问题?
我的对话代码:
public class DialogCreamodListas extends Dialog
implements OnClickListener
{
static EditText etxLISTArecep;
static EditText etxPRESUPUESTOrecep;
ImageView mImageViewImagen1;
ImageView mImageViewImagen2;
Button btnAceptar;
Context mContext;
static Long ID_LISTA;
static DbAdapter mDbHelper;
public DialogCreamodListas(Context context, long ID_LISTA, DbAdapter mDbHelper){
super(context);
mContext = context;
LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater
.inflate(R.layout.dialogcreamodlist, null);
setContentView(view);
DialogCreamodListas.ID_LISTA = (long) ID_LISTA;
DialogCreamodListas.mDbHelper = mDbHelper;
this.setTitle("Crea o modifica una lista");
mImageViewImagen1 = (ImageView) this.findViewById(R.id.image1);
mImageViewImagen1.setImageResource(R.drawable.mascarrito);
mImageViewImagen2 = (ImageView) this.findViewById(R.id.image2);
mImageViewImagen2.setImageResource(R.drawable.edit2);
etxLISTArecep = (EditText) findViewById(R.id.etxNombreLista);
etxPRESUPUESTOrecep = (EditText) findViewById(R.id.etxPresupuesto);
CargaInformacion();
btnAceptar = (Button) findViewById(R.id.btn_aceptar);
btnAceptar.setOnClickListener(this);
}
private void CargaInformacion()
{
if(ID_LISTA != null && ID_LISTA != -1)
{
Cursor Lista = mDbHelper.RecuperaRegistros(DbAdapter.TABLA_LISTAS,ID_LISTA);
((Activity) mContext).startManagingCursor(Lista);
etxLISTArecep.setText(Lista.getString(Lista.getColumnIndexOrThrow(DbAdapter.LISTA)));
etxPRESUPUESTOrecep.setText(Lista.getString(Lista.getColumnIndexOrThrow(DbAdapter.PRESUPUESTO)));
}
}
public void onClick(View v) {
if (v == btnAceptar)
{
//AQUI RECUPERO LOS DATOS Y ALMACENO EN BBDD
GuardaDatos();
CargarDatos();
dismiss();
return;
}
}
public static void GuardaDatos()
{
try
{
String[] Valores;
if(ID_LISTA == null || ID_LISTA == -1)
{
Valores = new String[]{null,etxLISTArecep.getText().toString(),etxPRESUPUESTOrecep.getText().toString()};
long id= mDbHelper.creaRegistro(DbAdapter.TABLA_LISTAS,Valores);
if(id>0)
{
ID_LISTA=id;
}
}
else
{ Valores = new String[]{ID_LISTA.toString(),etxLISTArecep.getText().toString(),etxPRESUPUESTOrecep.getText().toString()};
mDbHelper.actualizaRegistro(DbAdapter.TABLA_LISTAS,Valores);
}
}
catch(Exception E)
{
Log.e("EditaListas","Error: "+E);
}
}
public void CargarDatos()
{
if (this.mContext instanceof AdminListas)
{
((AdminListas) this.mContext).CargaDatos();
}
else
{
Cursor ListaCursor= mDbHelper.RecuperaRegistrosTabla(DbAdapter.VISTA_LISTAS);
((Activity) this.mContext).startManagingCursor(ListaCursor);
String[] Origen = new String[]{DbAdapter.LISTA,DbAdapter.PRESUPUESTO,DbAdapter.ARTICULOS,DbAdapter.DIFERENCIA};
int [] Destino = new int[]{R.id.txvnombrelista,R.id.txvpresupuesto,R.id.txvarticulos,R.id.txvdiferencia};
SimpleCursorAdapter listas = new SimpleCursorAdapter(this.getContext(),R.layout.registrodetallelista,ListaCursor,Origen,Destino);
((ListActivity) this.mContext).setListAdapter(listas);
}
}
}
【问题讨论】:
-
你的对话代码在哪里?我认为您可能会自己忽略解雇!
-
我已经用代码编辑了帖子;)