首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在android studio中创建选择所有按钮的逻辑?

如何在android studio中创建选择所有按钮的逻辑?
EN

Stack Overflow用户
提问于 2022-06-13 13:02:28
回答 2查看 47关注 0票数 1

这里有按钮列表,其中如果单击loop,我必须将它们作为0插入到sql表中,如果单击“确定”,我必须将其插入为1,则客户要求包括选择除选定的“not”以外的所有按钮,并将其插入到表中,如何使用for循环添加所有按钮输入,除非使用条件状态*

代码语言:javascript
复制
<?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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-13 13:29:42

1-创建所有按钮的列表,无论是动态的还是静态的,都由您决定。

2-创建一个字典,键是列表中的按钮id,值是checkBox.isChecked()。或者,检查复选框是否选中,并在单独列表中插入返回true的所有if。

票数 1
EN

Stack Overflow用户

发布于 2022-06-13 13:23:15

除非使用AccessibilityService,否则不能单击该按钮。因此,您需要调用一个在单击目标按钮时调用的函数。

在您的情况下,您需要调用按钮列表的所有函数。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72603354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档