Reputation: 1432
hello in my application contain listview.listview contain footer which contain next button whan user press next button listview adapter are refreshed and new question are populated using notify data set changed method.but i want to set a message when data is empty which are read from a json file(Dynamic json file comming from the server). i used setEmptyView method but it will hide listview and my footer also hide so user can not move to next set of question. and i am not extending listview. extends a custom baseadapter please guide me i am new in android
**
Update:-
** i solved it using creating textview addview into xml and return customeview. my getview method shown below.any other way can i do this. can this code may impact on the app performance. beacause i am inflecting another view please guide me
@Override
public int getCount()
{
if(itemDetailarraylist.size()==0)
return 1;
else
return itemDetailarraylist.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (itemDetailarraylist.size() == 0) {
TextView message = new TextView(context);
message.setText("No Data Found on This Section");
message.setTextSize(20);
message.setLayoutParams(new LinearLayout.LayoutParams(
(int) LinearLayout.LayoutParams.WRAP_CONTENT,
(int) LinearLayout.LayoutParams.WRAP_CONTENT));
convertView = inflater.inflate(R.layout.nodatafound_message,null);
((LinearLayout)convertView).setGravity(Gravity.CENTER);
((LinearLayout)convertView).addView(message);
return convertView;
} else {
ViewHolder holder;
if(convertView==null)
{------}}
}
Upvotes: 1
Views: 1609
Reputation: 1432
Update:-
** i solved it using creating textview addview into xml and return customeview. my getview method shown below.any other way can i do this. can this code may impact on the app performance. beacause i am inflecting another view please guide me
@Override
public int getCount()
{
if(itemDetailarraylist.size()==0)
return 1;
else
return itemDetailarraylist.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (itemDetailarraylist.size() == 0) {
TextView message = new TextView(context);
message.setText("No Data Found on This Section");
message.setTextSize(20);
message.setLayoutParams(new LinearLayout.LayoutParams(
(int) LinearLayout.LayoutParams.WRAP_CONTENT,
(int) LinearLayout.LayoutParams.WRAP_CONTENT));
convertView = inflater.inflate(R.layout.nodatafound_message,null);
((LinearLayout)convertView).setGravity(Gravity.CENTER);
((LinearLayout)convertView).addView(message);
return convertView;
} else {
ViewHolder holder;
if(convertView==null)
{------}}
}
Upvotes: 0
Reputation: 185
see this link
How do I set an empty view for ListViews in an activity with multiple ListViews?
<TextView android:id="@+id/empty_view"
android:layout_width="fill_parent"
android:layout_height="60px"
android:text="@string/empty_text"
/>
mListView.setEmptyView(findViewById(R.id.empty_view));
Upvotes: 1