当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); 

版权声明:本文为博主原创文章,未经博主允许不得转载。

你可能感兴趣的:(当Listview为空时显示提示字符,并且不为ListActivity的子类)