xamarin - 创建一个活动以提供多个选项以供选择
问题描述
我是新的 Xamarin android 开发。如果问题听起来很简单,请原谅。我正在创建一个表单,我需要为用户提供选择多个选项的选项,类似于复选框组。选项的数量可能更大,例如 10-20。我不是要使用哪个控件或布局,以便用户轻松阅读和选择选项。我尝试使用线性和垂直选项进行布局,但这看起来不太好。此外,如何基于某些数据源以编程方式创建这些选项。请建议我设计这个的最佳方法。任何帮助将不胜感激。这是我的 axml 中的片段
我尝试使用 LinearLayout 并使用了复选框控件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/blogging"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blog"/>
<CheckBox
android:id="@+id/game"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Game" />
解决方案
Found what I was looking for. It's called the Switch tool. So to provide settings page like options, I'll use this instead of checkboxes
<Switch
android:id="@+id/blogging"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Widget.AppCompat.CompoundButton.Switch"
android:hint="Blog"
/>
<Switch
android:id="@+id/game"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Widget.AppCompat.CompoundButton.Switch"
android:text="Game" />
推荐阅读
- r - 如何访问闪亮服务器上输入矩阵列表的每个元素?
- django - Django 中间件不起作用的模板
- scala - Spark Dataframe 基于动态选择的列提取列
- javascript - JSON - 在不选择(选择)子节点名称的情况下获取子节点的信息
- arrays - 重击。如何在同一时间插入"和'中
- visual-studio - 如何使用 tf 命令创建没有映射的工作区?
- javascript - 在 SiteOrigin 小部件之间将 php var 传递给 js
- javascript - HTML 页面不会在移动设备上滚动
- java - 是否可以让 Log4J 2 将所有内容保存在内存中并按需输出?
- pytorch - 如何消除 Pytorch 中的就地操作错误?