How to make the TextView invisible when there are items in listView?
- by Raphael Thomas Liewl
I like to display textView when there are no items in the listView whereas the textView will not display when there are items in the listView. My problem is even there are items in the listView, the textView still will be displayed in a short time and then load the items into listView. So, how to make the TextView invisible when there are items in listView?
Here is the codes:
public void onCreate(Bundle savedInstancesState){
super.onCreate(savedInstancesState);
setContentView(R.layout.list_screen);
user = getIntent().getExtras().getString("user");
Log.d("dg",user);
getList();
lv = (ListView) findViewById(android.R.id.list);
emptyText = (TextView)findViewById(android.R.id.empty);
lv.setEmptyView(emptyText);
}
list_screen.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/no_friend"
android:gravity="center_vertical|center_horizontal"/>
</LinearLayout>