Android 如何在listview中使用水平滚动?
我正在开发一款android应用程序。创建了包含不同布局的Android 如何在listview中使用水平滚动?,android,listview,horizontalscrollview,Android,Listview,Horizontalscrollview,我正在开发一款android应用程序。创建了包含不同布局的布局 还有一个列表视图。我使用了自定义适配器用于列表视图。我想在列表视图中显示水平滚动。但当我在其中应用水平滚动时,它会为每个项目显示。但不是在最后 请建议我如何应用这个 代码如下:- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" and
布局
还有一个列表视图
。我使用了自定义适配器用于列表视图。我想在列表视图中显示水平滚动。但当我在其中应用水平滚动时,它会为每个项目显示。但不是在最后
请建议我如何应用这个
代码如下:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg" >
<include
android:id="@+id/mainScreenHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/main_screen_header" />
<include
android:id="@+id/mainScreenListHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/mainScreenHeader"
layout="@layout/main_screen_list_header" >
</include>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="270dp"
android:layout_below="@+id/mainScreenListHeader"
android:cacheColorHint="#00000000"
android:drawSelectorOnTop="false" />
<include
android:id="@+id/mainScreenFilterClient"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/list"
android:layout_marginTop="10dp"
layout="@layout/main_screen_filter_client" >
</include>
<include
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/mainScreenFilterClient"
android:layout_marginTop="10dp"
layout="@layout/footer" >
</include>
在dev smart上有一篇关于这方面的优秀文章
检查这篇在dev smart上有一篇关于这方面的优秀文章
选中此项在xml
文件中声明水平列表视图
:
HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
在xml
文件中声明HorizontalListView
:
HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
这对你有帮助
<com.devsmart.android.ui.horizontiallistview
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ddd">
这对你有帮助
<com.devsmart.android.ui.horizontiallistview
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ddd">
您应该在适配器中声明几种类型的视图来实现这一点。然后,对于每个元素,返回第一种类型的视图和最后一秒的水平滚动视图:
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public int getItemViewType(int position) {
return isLastPositionInList ? 1 : 0;
}
然后
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int itemViewType = getItemViewType(position);
switch(itemViewType) {
case 0:
// prepare here your usual view
case 1:
// prepare here the horizontal view
您应该在适配器中声明几种类型的视图来实现这一点。然后,对于每个元素,返回第一种类型的视图和最后一秒的水平滚动视图:
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public int getItemViewType(int position) {
return isLastPositionInList ? 1 : 0;
}
然后
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int itemViewType = getItemViewType(position);
switch(itemViewType) {
case 0:
// prepare here your usual view
case 1:
// prepare here the horizontal view
我正在使用此库,您可以尝试此库:
我正在使用这个库,您可以试试这个:
我正在添加水平滚动,但它会显示在列表的每一项上。在列表视图的每一行上滚动。我正在添加水平滚动,但它会显示在列表视图的每一项上。在列表视图的每一行上滚动。安卓:orientation=“horizon…”应使用的位置。安卓:orientation=“horizon…”这应该在哪里使用。早些时候我在上面使用过,但我对此有一些问题。我不知道它可能对你有用。这是我之前使用的一些LIK,但我对此有一些问题。我不知道它可能对你有用。这里有一些喜欢的