last day (16 days later) » 

1:40 PM
0
A: It's possible to add ImageView programatically on ListFragment?

Bhavdip PatharHi If you extends the list fragment and want to set the image view when the list view is empty. android provide set empty view method for display the view when the list view has not data available.see below how to set the empty view. Below is the layout of my list fragment the layout content the...

 
I did it, but when I lauch it only shows the image inside the ItemList, I want to show it on the center no inside of the ListItem
 
I have updated the layout see empty_content.xml
If the empty view is showing even if your list view have data then simply set visibility gone in you layout. list view it self make it visible when the list view have not data to display.
let me update still if you have any question
 
I'm testing it wait :D
 
ok take you time :)
My solution will work in both case either if you extends ListFramgnet or Normal Fragment. if you extends the normal Fragment then you have to define empty using the object of list view such like mListiew.setEmptyView(findViewById(R.id.layout_empty)); other wise getListView() is available when you extends the ListFragment.
 
I think the thing that I'm doing wrong is at the time I check my cursor, let me edit my question with some code
 
1:40 PM
can you please update :)
It is another issue i think it is not related to the empty view. let me check
Hi can you debug the code, exception shown that the cursor index out of bound you try to access the index in cursor that are not available.
 
Hello, better continue here, we talked so much in comments :P
Mods may get angry
Instead of c == null now I've changed to
if (!c.moveToFirst()) {
getListView().setEmptyView(getActivity().findViewById(R.id.layout_empty));
}
 
no no do not write getListView().setEmptyView(getActivity().findViewById(R.id.layout_empty)); over ther it should inside you oncreate of the listview fragment
 
and now it doesn't crashes but not showing nothing
let me check
TESTING
 
I think you are doing wrong in two three points
 
in OnCreate it crashes
and in onViewCreated it doesn't shot anything
 
1:53 PM
can you share your code with me
 
yes
How can I?
 
are you using CVS ?
code version system or git
 
I can paste it on Pastebin
okay?
 
I made a Log.d
to see if the if(!c.movetofirst()) its visible
 
1:57 PM
ok let me check
 
and it shows to me the log
 
can you replace " while (c.moveToNext());" with this while(!aCursor.isAfterLast())
Hi are you there?
 
yes
 
getListView().setDivider(null);
getListView().setEmptyView(getActivity().findViewById(R.id.layout_empty)); write this two statment inside you onCreate(...)
currently you write inside your "onViewCreated" method.
 
this should be on onCreate?
 
2:04 PM
Yes correct
 
Let me test it
 
I have to leave my office now.
 
04-17 16:06:54.859 16146-16146/info.androidhive.slidingmenu E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: info.androidhive.slidingmenu, PID: 16146
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at info.androidhive.slidingmenu.MisOfertasFragment.onCreate(MisOfertasFragment.java:59)
u.u...
 
Your code is not proper, let me know what we have to do ?
 
The thing is that I want to do is : if cursor is not empty (there are data on my SQLITE) it will show the data on my list, BUT if c is null or empty just show an image on center of the fragment
 
2:20 PM
Only i can help if you can share your code with me.
 
we can use teamviewer
and then u can see my code
you there?
@BhavdipPathar
 

  last day (16 days later) »