2013-01-18 67 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