2013-01-18 43 views
0

我正在开发一个android应用程序。有包含不同布局的Layout创建。如何在列表视图中使用水平滚动?

其中还有listview。我使用custom adapter代替listview。我想在listview中显示水平滚动。但是当我在其中应用水平滚动时,它会显示每个项目。但最后没有。

请建议我如何应用此。下面

代码给出: -

<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> 

回答

1

有关于这一个外观极好文章DEV-智能

Horizontal Scroll in ListView

检查这个

+0

早些时候我使用上面,但我有这个问题。不知道可能会为你工作。 这里是一些链接http://stackoverflow.com/questions/22397715/touch-event-not-working-with-horizo​​ntal-list-view-devsmart-lib http://stackoverflow.com/questions/3240331/ horizo​​ntal-listview-in-android – rup35h

0

声明HorizontalListViewxml文件:

HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
+0

我正在添加水平滚动,但它出现在列表视图的每一行列表中.scroll的每个项目。 –

0

这将帮助你..

<com.devsmart.android.ui.horizontiallistview 
android:id="@+id/listview" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="#ddd"> 

android:orientation="horizontal" 
+0

android:orientation =“horizo​​n ...”这里应该使用。 –

0

您应该通过声明几种类型的意见做的适配器。那么对于每一个元素返回的第一个类型的视图,并为最后一个 - 第二这将是一个Horizo​​ntalScrollView:

@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