我是手机编程的新手,我现在有一些dificults。 我想写一些东西来设置密码DialogPrefence
。 我的问题是,如何从对话框中获取事件OnClick OK
?如何让DialogPreference POSITIVE_BUTTON在OnClick上工作?
这里是我的代码:
package com.kontrol.app;
import android.content.Context;
import android.content.DialogInterface;
import android.preference.DialogPreference;
import android.util.AttributeSet;
public class SS1_Senha extends DialogPreference implements DialogInterface.OnClickListener{
public SS1_Senha(Context context, AttributeSet attrs) {
super(context, attrs);
setPersistent(false);
setDialogLayoutResource(R.layout.ss1_senha);
setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//Action after OK
}
});
}
}
非常感谢!它像一个魅力! –
setNegativeButtonText(“CANCEL”); – Pawel