List View Inside A Scroll View
Solution 1:
I always find trying to put something that scrolls into something else that scrolls is a nightmare so I would probably put the top of your view (results Bangalore to Mysore Date) inside the ListView header,that way it will scroll off the screen
listView.addHeaderView(listViewHeader);
Solution 2:
They are right. You shouldn't place listview into scrollview. Instead of it try this:
<ScrollViewandroid:layout_width="fill_parent"android:scrollbars="vertical"android:layout_height="wrap_content"android:scrollbarStyle="insideOverlay"><LinearLayoutandroid:id="@+id/itemContainer"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="wrap_content"
><!-- YOUR ELEMENTS WILL BE PLACED HERE --></LinearLayout></ScrollView>
Then you can add items from code:
private LinearLayout container;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.YOUR_XML);
container = (LinearLayout)findViewById(R.id.itemContainer);
LinearLayout.LayoutParamslayoutParams=newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
/*CREATE YOUR ITEM*//*AND PLACE IT INTO CONTAINER*/
container.addView(YOUR_ITEM, layoutParams);
}
Solution 3:
Put the portion you've shown in red border in a ListView which has Custom List Items. You don't really need a scrollview I guess. Just set the sort and filter buttons to parent bottom. And The listview between the buttons and the part above the list items. Best of luck.
Solution 4:
I tried using ListView inside ScrollView by using my own code available as answer at below link. Its working fine for me. Check it once and try it if you feel its good.
Solution 5:
You can put a ListView inside a ScrollView. Just extend the ListView to override the onTouchEvent method. Like so
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
publicclassChildScrollViewextendsandroid.widget.ListView {
privateint parent_id;
publicChildListView(Context context) {
super(context);
}
publicChildListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
publicChildListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@OverridepublicbooleanonTouchEvent(MotionEvent event){
requestDisallowInterceptTouchEvent(true);
returnsuper.onTouchEvent(event);
}
}
Post a Comment for "List View Inside A Scroll View"