當尋找Device或列出IP時, 使用ListView時, 想在List 列表底下顯示”搜尋中或讀取中”的提示時
可使用FootView來達成.
Step 1: 新增footview.xml
在res/layout增加footview.xml
footview.xml1 2 3 4 5 6 7 8 9 10 11
| <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/list_foot" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/loading"/> </RelativeLayout>
|
Step 2: ListView add footview
MainActivity.java1 2 3 4 5
| ListView mDeviceList = (ListView) findViewById(R.id.device_list); mDeviceList.setOnItemClickListener(this); View footerView = ((LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.listview_foot, null, false); mDeviceList.addFooterView(footerView);
|
Step 3: 取消FootView的Divider
main_layout.xml1 2 3 4 5 6 7 8 9 10
| <ListView android:id="@+id/device_list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/title" android:layout_above="@+id/find_devices" android:layout_margin="5dp" android:divider="@color/colorPrimary" android:dividerHeight="1dp" android:footerDividersEnabled="false"/>
|