Android点击弹出选择框,既可以选择也可以输入,布局

 

<LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingStart="@dimen/dp_15"
                    android:paddingEnd="@dimen/dp_15">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:gravity="center_vertical"
                        android:text="  类  型:"
                        android:textColor="@color/text999"
                        android:textSize="@dimen/sp_14" />

                    <EditText
                        android:id="@+id/et_type"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="6"
                        android:background="@null"
                        android:gravity="center_vertical"
                        android:hint="请输入或者选择"
                        android:padding="@dimen/dp_15"
                        android:text=""
                        android:textColor="@color/text333"
                        android:textColorHint="@color/text999"
                        android:textSize="@dimen/sp_14" />
                    <LinearLayout
                        android:id="@+id/img_type"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent">
                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:src="@drawable/ic_right"
                            android:layout_marginStart="@dimen/dp_30"
                            android:layout_marginEnd="10dp"/>
                    </LinearLayout>
                </LinearLayout>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的 Android 代码示例,演示如何在按钮点击弹出提示: 1. 在你的 XML 布局文件中添加一个按钮控件: ```xml <Button android:id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="点击弹出提示" /> ``` 2. 在你的 Java 代码中获取按钮控件,然后为它设置点击事件监听器: ```java Button myButton = findViewById(R.id.my_button); myButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 在这里编写弹出提示的代码 } }); ``` 3. 在点击事件监听器中,使用 `AlertDialog.Builder` 类创建一个提示,并设置标题、消息和按钮: ```java AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("提示"); builder.setMessage("确定要执行这个操作吗?"); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // 在这里编写“确定”按钮被点击时的代码 } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // 在这里编写“取消”按钮被点击时的代码 } }); AlertDialog dialog = builder.create(); dialog.show(); ``` 这样,当用户点击按钮时,就会弹出一个提示,询问用户是否要执行某项操作。用户可以选择“确定”或“取消”按钮。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值