soonoo
soonoo

Reputation: 907

How to add a different form of item in Android listview

In an activity, I have a listview and a textview.

I want to make a bulletin board using those views. In my case, a listview means group of posts and a textview means page number.

So I write the code below:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" tools:context=".MainActivity">
    <ListView
        android:id="@+id/referList"
        android:layout_width="match_parent"
        android:layout_height="500dp"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="[1]" // page number
        android:layout_below="@id/referList"/>
</RelativeLayout>

However .xml divides a whole screen and displays each view separately.(Because I set a listview's height "500dp")

What should I do to make a view like this in Android? (https://www.google.com/webhp?hl=en&gws_rd=cr,ssl&ei=pJzLVMbBC-HRmwWL3oGgBw&fg=1#hl=en&q=listview - When reaches end of the scroll, then page number appears.)

Upvotes: 0

Views: 103

Answers (1)

Sam Bains
Sam Bains

Reputation: 548

Try adding the page number view as a footer to the list

View footerView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
ListView.addFooterView(footerView);

Upvotes: 0

Related Questions