Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.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 特定按钮拒绝在Android Studio中工作_Java_Android - Fatal编程技术网

Java 特定按钮拒绝在Android Studio中工作

Java 特定按钮拒绝在Android Studio中工作,java,android,Java,Android,我有两个按钮,似乎有相同的功能。当我将“switchMode”方法放在“buttonMode”中时,它不起作用。但当我把“开关模式”放在“按钮背景灯”中时,它工作正常,尽管我没有改变任何东西 以下是按钮: <Button android:id="@+id/buttonMode" android:layout_width="50dp" android:layout_height="50dp" android:background="@android:color

我有两个按钮,似乎有相同的功能。当我将“switchMode”方法放在“buttonMode”中时,它不起作用。但当我把“开关模式”放在“按钮背景灯”中时,它工作正常,尽管我没有改变任何东西

以下是按钮:

<Button
    android:id="@+id/buttonMode"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:background="@android:color/transparent"
    android:onClick="switchMode"
    android:soundEffectsEnabled="false"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.584" />

<Button
    android:id="@+id/buttonBackLight"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:background="@android:color/transparent"
    android:soundEffectsEnabled="false"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.399" />

这些按钮使用的是什么布局?ConstraintLayout。项目本身模拟了数字手表,它有三个按钮。你在布局上看到两个按钮了吗?尝试更改那些
按钮的文本,然后再次签出。我在布局上看到两个按钮。它们根本不包含文本。我尝试将buttonMode放在不同的位置,但仍然无法使用两个按钮的click register粘贴java代码
public void switchMode(View view) {
        if(mainScreenViewsAreVisible) {
            twentyFourHoursFormat = !twentyFourHoursFormat;
            swapTimeFormatVisibility();
           }
        if(stopWatchViewsAreVisible){
            isRunning = true;
           }
        }