Add different first view to GridView in Android -
i want have in gridview
first item different others. gridview's adapter can either adapter extending cursoradapter
or arrayadapter
. depending on images path taken - db, or arraylist.
for works fine, want have first element different rest. first element, no matter adapter, has empty element button can add elements. image in first element has resource, while images rest of elements form uri.
also, there emptyview
of gridview
set. i've tried adding first element arraylist @ beginning, empty view not shown. also, don't know how work content db. honest haven't got more idea, , cannot find in google.
do know way can add first view?
i need work on api10 , above.
you have 2 options
- in adapter, can check if position 0 inflate other view.
more complex seems better 1 override (assuming using arrayadapter) methods:
getitemviewtype(int position) getviewtypecount()
you can find nice , friendly example here
--- edit ---
to show empty view need sure that:
- your view inflated correctly.
- you called mgridview.setemptyview(view);
- there no items show in adapter, means in grid view adapter function getcount() returns 0. note function should implement correct logic after implements 2 methods i've mentioned above.
Comments
Post a Comment