代码如下:
@Override
public void onClick(View v) {
//清空个人信息
if(v==sp_voice_lib_import){
Dialog dialog = new AlertDialog.Builder(this)
.setIcon(R.drawable.dialog_icon)
.setTitle("清空个人信息")
.setMessage("确定要清空个人信息吗?")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Toast.makeText(study_setting.this, "个人信息已清空", Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
intent.setClass(study_setting.this, UserLogin.class);
startActivity(intent);
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).create();
dialog.show();
}
}
执行到dialog.show();报错:
------解决方案--------------------
Dialog dialog = new AlertDialog.Builder(study_setting.this)
------解决方案--------------------
Dialog dialog = new AlertDialog.Builder(study_setting.this.getParent())
试试study_setting.this.getParent()