Android-具有单选单选按钮的列表视图
我有一个包含2个单选按钮项的列表视图。当它从布局中膨胀时,它恰好是可滚动的,即使有很多空间,如下所示。 如屏幕截图所示,我有两个单选按钮。 1.距离 2.评级 但是“评级”单选按钮不可见,我必须滚动查看它。为什么会发生这种情况。我尝试将布局高度设置为包裹内容、填充父对象和匹配父对象。但这并没有解决问题。知道为什么会这样吗 这里我引用的是列表视图:Android-具有单选单选按钮的列表视图,android,listview,radio-button,Android,Listview,Radio Button,我有一个包含2个单选按钮项的列表视图。当它从布局中膨胀时,它恰好是可滚动的,即使有很多空间,如下所示。 如屏幕截图所示,我有两个单选按钮。 1.距离 2.评级 但是“评级”单选按钮不可见,我必须滚动查看它。为什么会发生这种情况。我尝试将布局高度设置为包裹内容、填充父对象和匹配父对象。但这并没有解决问题。知道为什么会这样吗 这里我引用的是列表视图: ListView radio_list = (ListView) view.findViewById(R.id.RadioList); radio_l
ListView radio_list = (ListView) view.findViewById(R.id.RadioList);
radio_list.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_single_choice,
radio_list_items));
radio_list.setItemsCanFocus(true);
radio_list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
ListView radio\u list=(ListView)view.findViewById(R.id.RadioList);
radio_list.setAdapter(新阵列适配器)(此,
android.R.layout.simple\u list\u item\u单选,
无线电(列表(项目));
radio_list.setItemsCanFocus(真);
radio_list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
我的xml:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:paddingLeft="10dp"
android:text="SEARCH"
android:textColor="#FF3300"
android:textSize="20dp" >
</TextView>
</LinearLayout>
<RelativeLayout
android:id="@+id/searchTextLayout"
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="20dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="20dip"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/searchTextButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:background="#685E5C"
android:contentDescription="Sample"
android:scaleType="fitCenter"
android:src="@drawable/abs__ic_search" />
<EditText
android:id="@+id/searchText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/searchTextButton"
android:background="@drawable/background_black_border_full"
android:padding="8dp"
android:textColor="@android:color/white" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:paddingLeft="10dp"
android:text="SORT BY"
android:textColor="#FF3300"
android:textSize="20dp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/RadioList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
</LinearLayout>
您的布局xml文件很奇怪 首先,你应该简化它: 在LinearLayout=>中只有一个元素是没有意义的,这意味着相应的线性布局是无用的 第二点:如果线性布局中有2个子项,且第一个子项的高度为“匹配父项”,且未设置任何布局权重,则第二个子项将被推出,因为没有任何剩余空间。(这可能是你的问题) 第三点:您使用的是相对布局作为线性布局,证据是您尝试在其上使用的android:orientation参数。这是无用的。相对布局子体的位置由它们之间的相对定位给出。在本例中,可以使用方向为水平的线性布局,而不是相对线布局 帮助您的最佳建议:简化布局xml
是行
ListView radio\u list=(ListView)view.findViewById(R.id.RadioList)代码>来自onCreate()
还是其他地方?还有,这里的视图是什么?它来自我的SlidingFragment类的onCreateView,它扩展了SherlockFragment。另外,“视图=充气机。充气(R.layout.list,container,false);”我正在构建一个示例应用程序来实现滑动菜单。因此,我将返回“查看”到我的SlidingFragmentActivity以显示滑动菜单。