我是手機編程的新手,我現在有一些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