0

Currently I am trying to create somethine like this in xml. User able to scroll the whole page instead of listview only. Anyone got idea how to create this XML or any suggestion use what to replace list view.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="plaza_semanggi.lippomalls.lippoapp.Screens.HomeFragment"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width ="wrap_content"
    android:layout_height ="wrap_content"
    card_view:cardCornerRadius= "5dp"
    android:layout_weight="5"

    >
    <android.support.v4.view.ViewPager
        android:id="@+id/home_viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

</android.support.v7.widget.CardView>

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="5"></ListView>


</LinearLayout>

enter image description here

beginnerK
  • 404
  • 1
  • 5
  • 20

2 Answers2

1

Don't use Scrollview ....Only use ListView and Create two view first for viewpager and second for your list item view. Add Viewpager view in first row of listview and remaining for list item.

Use following changes in adapter

@Override
public int getItemViewType(int position) {
    // TODO Auto-generated method stub

    boolean strViewPagerFlage=arraylist.get(position).getviewpageflage();
    //get 
    if(strViewPagerFlage){  
    //For ViewPager
    return 0;   
    }else{
    //For ListItem
      return 1;
    }

}

@Override
public int getViewTypeCount() {
    // TODO Auto-generated method stub
    return 2;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub

    View view = convertView;
     if(position == 0){
        view = inflater.inflate(R.layout.view_pager_layout, null);
    }else{
        view = inflater.inflate(R.layout.list_item, null);
    }

}
0

One possibility is to put your whole stuff in the Listview. The first position of your list adapter would return the CardView with the Viewpager and the following positions return your other list entries.

Christopher
  • 9,682
  • 7
  • 47
  • 76