0

I am working on an android app. There is Layout created in which different layout included.

There is a listview also in it. I used custom adapter for listview . I want to show horizontal scroll in listview .But when i apply horizontal scroll in it, it shows for each item. but not in last.

Please suggest how can i apply this.

code is given below:-

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

hemantsb
  • 2,049
  • 2
  • 20
  • 29
Nitesh Kabra
  • 509
  • 2
  • 9
  • 17

5 Answers5

2

I am using this library you cal try this one:

https://github.com/sephiroth74/HorizontalVariableListView

rupesh
  • 2,865
  • 4
  • 24
  • 50
1

There is an excelent article about this on dev-smart

Horizontal Scroll in ListView

check this

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
  • earlier i was using above but i had some issue with this. Don't know may be it will be working for you. Here is some liks http://stackoverflow.com/questions/22397715/touch-event-not-working-with-horizontal-list-view-devsmart-lib http://stackoverflow.com/questions/3240331/horizontal-listview-in-android – rupesh Mar 14 '14 at 16:21
0

Declare the HorizontalListView in the xml file:

    HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fillViewport="true" 
Zombie
  • 1,965
  • 2
  • 20
  • 34
deepak825
  • 432
  • 2
  • 8
0

This will Help you..

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

or

android:orientation="horizontal"
Zombie
  • 1,965
  • 2
  • 20
  • 34
Vela
  • 87
  • 11
0

You should do it in the Adapter by declaring several types of views. Then for every element you return the 1st type of view and for last one - second which would be a HorizontalScrollView.:

@Override
public int getViewTypeCount() {
    return 2;
}

@Override
public int getItemViewType(int position) {
    return isLastPositionInList ? 1 : 0;
}

and then

@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
Stan
  • 6,511
  • 8
  • 55
  • 87