这里有按钮列表,其中如果单击loop,我必须将它们作为0插入到sql表中,如果单击“确定”,我必须将其插入为1,则客户要求包括选择除选定的“not”以外的所有按钮,并将其插入到表中,如何使用for循环添加所有按钮输入,除非使用条件状态*
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Inspection"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:id="@+id/date_ins"
/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.01"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="EOL Inspection-2"
android:layout_weight="0.5"
/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.01"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Shift A: Operator"
android:layout_weight="0.2"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vehicle Inspection"
android:layout_gravity="center"
android:textSize="30dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vin No:"
android:textSize="20dp"/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.01"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center"
android:textSize="20dp"
android:id="@+id/vin_ins"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Inspection Name"
android:textSize="20dp"
android:background="@drawable/border_2"
/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.01"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="OK"
android:textSize="20dp"
android:gravity="center"
android:layout_weight="0.5"
android:background="@drawable/border_2"
/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.01"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="NOT OK"
android:textSize="20dp"
android:gravity="center"
android:layout_weight="0.5"
android:background="@drawable/border_2"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BODY SHOP "
android:layout_gravity="center"
android:textSize="25dp"
android:textStyle="bold"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/serial_number_punching"
android:layout_width="0dp"
android:layout_height="75dp"
android:textSize="17dp"
android:text="Serial Number Punching and Scanning"
android:layout_weight="0.8"
/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.01"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.45"
android:text="OK"
android:backgroundTint="#807C7C"
android:id="@+id/ok_1"
android:layout_marginTop="10dp"
/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.05" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NOk"
android:id="@+id/nok_1"
android:backgroundTint="#807C7C"
android:layout_marginTop="10dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:layout_width="0dp"
android:layout_height="110dp"
android:textSize="17dp"
android:text="Boat Tightening With Chassis ,Front Wind Shield Panel Tightening With Chassis"
android:layout_weight="0.8"
android:id="@+id/boat_tight"
/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.01"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.45"
android:text="OK"
android:id="@+id/ok_2"
android:backgroundTint="#807C7C"
android:layout_marginTop="20dp"
/>
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.05" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#807C7C"
android:text="NOk"
android:id="@+id/nok_2"
android:layout_marginTop="20dp"
/>
</LinearLayout>发布于 2022-06-13 13:29:42
1-创建所有按钮的列表,无论是动态的还是静态的,都由您决定。
2-创建一个字典,键是列表中的按钮id,值是checkBox.isChecked()。或者,检查复选框是否选中,并在单独列表中插入返回true的所有if。
发布于 2022-06-13 13:23:15
除非使用AccessibilityService,否则不能单击该按钮。因此,您需要调用一个在单击目标按钮时调用的函数。
在您的情况下,您需要调用按钮列表的所有函数。
https://stackoverflow.com/questions/72603354
复制相似问题