我在按钮的onclick后面创建了一个警告对话框,但是当我单击该按钮时,它使应用程序崩溃,并引发以下异常。
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
在logcat中我无法理解的07-13 11:51:12.445 21054-21054 / com.vshine.neuron.riseshine E / MultiWindowProxy:getServiceInstance失败!
,因为我是编码新手,所以随附了.Java和Logcat屏幕截图。 这是Logcat:
这是.java类:
答案 0 :(得分:0)
只需尝试继承Activity
而不是AppCompatActivity
到您的quiz.java
活动
像在代码顶部
public class Quiz extends Activity{
更多支票this post.
答案 1 :(得分:0)
好吧,我认为您需要提供活动的背景信息。 试试这个:
new AlertDialog.Builder(YourClassName.this)
.setTitle("Title")
.setMessage("Message?")
.setCancelable(false)
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Function on no
})
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Function on yes
}
})
.show();