0

I would like to ask how can i display included layout and listview positioned under the included in onde view.

Layout:

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/swipeContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activity.TransactionsActivity">
    <include
        android:layout_width="fill_parent"
        android:layout_height="10dp"
        android:layout_alignParentTop="true"
        layout="@layout/preloader" />

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list"
        />

</android.support.v4.widget.SwipeRefreshLayout>

In the preview is displayed only the included layout, but lisview below is not displayed.

Many thanks for any advice.

redrom
  • 11,502
  • 31
  • 157
  • 264
  • You need to use a header view: http://stackoverflow.com/questions/7978359/using-listview-how-to-add-a-header-view – Juan Martinez Feb 01 '17 at 15:53
  • About the specific example you posted, as you can read here: https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html SwipeRefreshLayout can host only one direct child – Valentino Feb 01 '17 at 16:08

1 Answers1

0

Since SwipeRefreshLayout accept only one child. Wrap it inside LinearLayout or RelativeLayout.

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.TransactionsActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <include
        layout="@layout/preloader"
        android:layout_width="fill_parent"
        android:layout_height="10dp"
        android:layout_alignParentTop="true" />

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

Best Of Luck.

DevThapa
  • 173
  • 2
  • 12