Custom Listview Adapter, adding a static footer and understanding of R.id.list

I don’t get something, and I am looking for help in understanding what is happening here.

I have a custom list adapter (which just extends the BaseAdapter) that I have successfully used to create and display a list. Now I want to add a static footer at the end of my list. After looking at several resources (in particular this one), I realized that my reluctance to use XML should come to an end, and set up the following xml layout in a file called devices_list.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:id="@+id/bottom_control_bar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">
    <ToggleButton android:id="@+id/bottom_control_toggle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:textOff="Filter Favourites OFF" 
        android:textOn="Filter Favourites ON"/>
</LinearLayout>
<ListView android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="0dip" 
    android:layout_above="@id/bottom_control_bar">
</ListView>
<TextView android:id="@android:id/empty" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:text="@string/main_empty_list"
    android:layout_above="@id/bottom_control_bar"/>
  </RelativeLayout>

, , . ( , ), , , .

    @Override
    public void onCreate(Bundle savedInstanceState){
       super.onCreate(savedInstanceState);
       this.setContentView(R.layout.devices_list);

       db = new DbManager(this);
       db.open();

       AllCur = db.fetchAllDevices();
       startManagingCursor(AllCur);

       list = new DeviceListAdapter(this, AllCur);   //make my custom list adapter                  
       setListAdapter(list);
            }

ListView, xml DeviceListAdapter? , , . .

+3
1

ListView, TextView android:layout_above="@id/bottom_control_bar", , TextView ListView. , ListView 0dip, .

ListView TextView (android:layout_alignParentTop="true").

ListView, xml DeviceList?

, setListAdapter().

+1

Source: https://habr.com/ru/post/1753192/


All Articles