android - GridView elements randomly repositioned after scrolling -
so, i'm having weird problem gridview on app.
what want pretty simple: want list of installed apps (a-la app drawer) , display them in alphabetical order in gridview.
it works pretty well, show nicely, scroll down see more apps , scroll up, apps @ top offselt. vertically, more exact, , happens every time scroll down more 1-2 rows , scroll way up.
also, i'll scroll top , it'll keep scrolling past top apps oblivion, , not let me scroll down. i'm not sure if problems related, i'd sure fix both of them. gridview resets normal after clicking on 1 of items or switching windows in app.
this 2nd day working android layouts , such, although i've done java programming long time before, might missing i'm not new this.
i've looked online , can't quite find answer works, i've tried ones i've found , i'm coming accross solutions have implemented in code, i'm not sure go besides here.
i'm not sure part of code post figure out problem, , don't want turn huge wall of text every 1 of related files, appreciate lot if guide me show.
i'll start gridview layout, individual cell layout, , adapter's getview method, seem places of solutions found guided to. please let me know if need more of code.
layout_grid
<gridview android:id="@+id/gridview1" android:layout_width="match_parent" android:layout_height="488dp" android:numcolumns="5" android:textalignment="center" android:verticalspacing="5dp" > </gridview> </linearlayout>
layout_app
<imageview android:id="@+id/ivicon" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginright="5dip" android:scaletype="center" android:adjustviewbounds="true" /> <textview android:id="@+id/tvname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" /> </linearlayout>
getview
public view getview(int position, view convertview, viewgroup parent) { view v; if(convertview == null){ v = layoutinflater.from(mcontext).inflate(r.layout.layout_app, null); //mcontext defined in constructor adapter }else{ v = convertview; } imageview icon = (imageview)v.findviewbyid(r.id.ivicon); textview name = (textview)v.findviewbyid(r.id.tvname); icon.setimagedrawable(getitem(position).geticon()); name.settext(getitem(position).getname()); //geticon , getname custom app class made store app info. return v; }
i have pictures of looks like, it's not letting me post them or give links of them because of reputation, if want see ask me.
p.s.: minor problem i'm having icons don't seem scaling down size of imageview, that's totally unrelated far know , not major point of post. can me if want, though :p
i figured out, although i'm not sure why happening. apparently, since didn't have hardcoded height individual cells, adjust text around them , change size, therefore changing position of other ones. still don't know why whole overscrolling thing happens, think it's bug gridview find weird no-one else has mentioned it. oh well...
Comments
Post a Comment