Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我在一个活动中有两个按钮。当我点击它们时,我会做出新的意图,这样我就可以制作一个新的屏幕。一个有效,另一个无效';T_Java_Android - Fatal编程技术网

Java 我在一个活动中有两个按钮。当我点击它们时,我会做出新的意图,这样我就可以制作一个新的屏幕。一个有效,另一个无效';T

Java 我在一个活动中有两个按钮。当我点击它们时,我会做出新的意图,这样我就可以制作一个新的屏幕。一个有效,另一个无效';T,java,android,Java,Android,我的java代码: Button equations = (Button) findViewById(R.id.algebrabutton); equations.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(view.getContext(),

我的java代码

 Button equations = (Button) findViewById(R.id.algebrabutton);
    equations.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), 
             algebra_activity.class);
            startActivityForResult(myIntent, 0);
        }
    });


    Button word = (Button) findViewById(R.id.wordbutton);
    word.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view1) {
            Intent myIntent1 = new Intent(view1.getContext(), 
               word_activity.class);
            startActivityForResult(myIntent1, 0);
        }
    });
错误日志

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lawrencej.mathappdeluxe/com.exampl‌​e.lawrencej.mathappd‌​eluxe.algebra_activi‌​ty}: 
java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor.
Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead

当我单击word按钮时,它工作正常并显示一个新屏幕。当我单击“公式”按钮时,应用程序崩溃。我做错什么了吗?

在你的
风格中使用这个

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

显示你的错误日志。android studio上没有错误,应用程序只是在我的手机上崩溃,所以我不知道是否有错误日志错误日志在android studio中。。。java.lang.RuntimeException:无法启动活动ComponentInfo{com.example.lawrencej.mathappdeluxe/com.example.lawrencej.mathappdeluxe.algebra_activity}:java.lang.IllegalStateException:此活动已具有由窗口装饰提供的操作栏。不要请求Window.FEATURE\u SUPPORT\u ACTION\u BAR,并在主题中将windowActionBar设置为false以使用工具栏。哦,我明白了,显然我没有工具栏。这解决了我的问题,感谢您指出错误日志的位置:)
<activity
    android:name=".algebra_activity"
    android:theme="@style/AppTheme.NoActionBar">