Android 如何布局对话框=>;滚动视图=>;可扩展列表视图?
我想在我的Android应用程序中显示一个对话框,让用户更改一些选项 我的此对话框布局计划是:Android 如何布局对话框=>;滚动视图=>;可扩展列表视图?,android,android-layout,Android,Android Layout,我想在我的Android应用程序中显示一个对话框,让用户更改一些选项 我的此对话框布局计划是: 对话 滚动视图包装所有选项 选项组1-ExpandableListView 选项组2-如上所述 顶级选项A-CheckedTextView 顶级选项B-CheckedTextView 顶层选项C-CheckedTextView 确定/取消按钮 但是,当我尝试获得正确的布局时,最终要么是选项组被折叠,使ExpandableListView的高度仅与第一个组相同,要么是ExpandableLi
- 对话
- 滚动视图包装所有选项
- 选项组1-ExpandableListView
- 选项组2-如上所述
- 顶级选项A-CheckedTextView
- 顶级选项B-CheckedTextView
- 顶层选项C-CheckedTextView
- 确定/取消按钮
- 滚动视图包装所有选项
有没有一个简单的方法来让这个布局正常工作?如果不是,我应该如何代表一个具有两个选项组和顶层选项的选项菜单?
你应该考虑重新编写你的应用程序的一部分,在对话框中有这么多的内容会迷惑用户。这个对话框是为了简短而简单的答案,而不是复杂的。是的<>我的建议是改变你的设计方法。 你应该考虑重新编写应用程序的这一部分,因为对话框中的内容太多会迷惑用户。对话框的意思是简短而简单的答案,而不是复杂的。
我的建议是更改您的设计方法。在新代码中使用PreferenceActivity和PreferenceFragment。这样,您就不会重新发明轮子,您的应用程序将与平台上的其他应用程序相适应。在新代码中使用PreferenceActivity和PreferenceFragment。这样,您就不会重新发明轮子,您的应用程序将与平台上的其他应用程序相适应平台。我已经看到了很多论点,认为将一个可滚动视图放在另一个可滚动视图中是行不通的。我非常确定这是不可能的。我已经看到了很多论点,认为将一个可滚动视图放在另一个可滚动视图中是行不通的。我非常确定这是行不通的。e在新活动中使用相同的布局,但在更大的窗口=>中出现相同的问题。我可以在新活动中使用相同的布局,但在更大的窗口=>中出现相同的问题。感谢您指出这些问题,我是Android新手,很高兴了解它们。在这种情况下,该对话框用于优化搜索选项-例如,美国er按文本搜索,然后单击“优化选项”按钮。在一个类别中,他们可以勾选州(如阿尔伯塔、不列颠哥伦比亚、马尼托巴)以将搜索限制在这些州,也可以勾选其他复选框以类似地限制搜索结果。我怀疑这些类别不适用于非永久性/非“设置”键入内容-是这样吗?感谢您指出这些内容,我是Android新手,很高兴了解它们。在这种情况下,该对话框用于优化搜索选项-例如,用户通过文本搜索,然后单击“优化选项”按钮。在一个类别中,他们可以勾选州(例如阿尔伯塔省、不列颠哥伦比亚省、马尼托巴省)将搜索限制在这些状态,他们可以勾选其他复选框以类似地限制搜索结果。我怀疑这些类不适用于非永久性/非“设置”类型的东西-对吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- ScrollView so that the user can see all the options
Without filling the entire dialog and losing the ok / cancel buttons
The height is hardcoded - I'd like to make it fill_parent -->
<ScrollView
android:background="#FFFF0000"
android:layout_weight="0.5"
android:layout_width="match_parent"
android:layout_height="300dp"> <!--RED-->
<!-- Linear layout around the options
ScrollView complains if it wraps multiple children -->
<LinearLayout
android:background="#FF00FF00"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> <!--GREEN-->
<!-- Option groups -->
<ExpandableListView
android:id="@+id/elvRefine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000FF" /> <!--BLUE-->
<!-- Top level options -->
<CheckedTextView
android:id="@+id/checkboxA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Top level option A" />
<CheckedTextView
android:id="@+id/checkboxB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Top level option B" />
<CheckedTextView
android:id="@+id/checkboxC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Top level option C" />
</LinearLayout>
</ScrollView>
<!-- OK, cancel buttons -->
<LinearLayout
android:background="#FFFFFFFF"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="right"> <!--WHITE-->
<Button
android:id="@+id/buttonOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK" />
<Button
android:id="@+id/buttonCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel" />
</LinearLayout>
</LinearLayout>
private Dialog getRefineDialog() {
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.refine_dialog);
dialog.setTitle("Refine options");
dialog.setCancelable(true);
final ExpandableListView elv =
(ExpandableListView) dialog.findViewById(R.id.elvRefine);
elv.setAdapter(new RefineAdapter(this));
elv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
// cancel button listener
Common.setSimpleCancelListener(dialog, R.id.buttonCancel);
return dialog;
}