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

  1. in adapter, can check if position 0 inflate other view.
  2. 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:

  1. your view inflated correctly.
  2. you called mgridview.setemptyview(view);
  3. 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

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -