當Listview爲空時顯示提示字符,而且不爲ListActivity的子類

TextView emptyView = new TextView(this);
emptyView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
 LayoutParams.FILL_PARENT));
emptyView.setText("你尚未歷史記錄");
emptyView.setPadding(8, 8, 8, 8);
emptyView.setTextSize(30);
emptyView.setGravity(Gravity.CENTER); 
emptyView.setVisibility(View.GONE); 
LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);    
addContentView(emptyView, params);    
lvrecords.setEmptyView(emptyView); 

版權聲明:本文爲博主原創文章,未經博主容許不得轉載。java

相關文章
相關標籤/搜索