问题
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>
回答1:
I am using this library you cal try this one:
https://github.com/sephiroth74/HorizontalVariableListView
回答2:
There is an excelent article about this on dev-smart
Horizontal Scroll in ListView
check this
回答3:
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"
回答4:
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"
回答5:
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
来源:https://stackoverflow.com/questions/14392461/how-to-use-horizontal-scroll-in-listview