2015-11-10 18 views
2

結束時,我知道如何在ListView項添加Ellipsized的TextView如下面的代碼三個圓點的ListView

android:singleLine="true" 
    android:maxEms="20" 
    android:ellipsize="end" 

我想在ListView中的末日,因爲指示將三個點的到達最後項目是什麼在listView中。檢查下面的鏈接,看看我想達到什麼。

https://www.dropbox.com/s/69hpe6z112p0wa3/example.png?dl=0

注:在ListView的項目是從數據庫

回答

7

填充使3個點的靜態視圖和頁腳添加到您的列表查看方式

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

我得到這個錯誤列表視圖下面:嘗試調用虛擬方法java.lang.Object繼承android.content.Context.getSystemService(java.lang.String中)「對空對象引用。 我創建線性佈局稱爲footer_layout並有三個點添加TextView的..我做錯了什麼? – Molan

+0

我刪除ActivityContext和它的工作,@Zubair Akber謝謝你們的幫助。 – Molan

4

只需添加腳註查看,並根據需要在列表的末尾顯示有創建佈局。

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

如果你想在你的不是這種方法最後一個項目結束,以顯示它是有用的,但如果你要顯示它在列表的末尾所有的時間比你可以添加頁腳視圖您佈局在XML文件中