android - Having trouble implementing two-way-gridview -


i think it's adapter problem lies, worked on normal gridview, assumed able switch two-way-gridview in place of gridview. 1 place used nothing shown , other place images don't fill view vertically , there more columns have set.

here's adapter code:

public final class covergridviewadapter extends baseadapter {     private final context context;     private final list<string> urls = new arraylist<string>();     private final arraylist<hashmap<string,string>> arraylist;  public covergridviewadapter(context context, arraylist<hashmap<string, string>> arraylist) {     this.context = context;     this.arraylist = arraylist; }  @override public view getview(int position, view convertview, viewgroup parent) {     // image url current position.     //string url = getitem(position);     final hashmap<string,string> game = getitem(position);      coverimageview view = (coverimageview) convertview;     if (view == null) {         view = new coverimageview(context);         view.setscaletype(center_crop);         view.setonclicklistener(new view.onclicklistener() {             public void onclick(view v) {                 intent myintent = new intent(context, gameactivity.class);                 myintent.putextra("key", game); //optional parameters                 context.startactivity(myintent);              }         });     }        // trigger download of url asynchronously image view.     picasso.with(context) //             .load(game.get(gamediscoveryfragment.tag_super_image)) //             .placeholder(r.drawable.ic_launcher) //todo: placeholder image             .error(r.drawable.ic_launcher) //todo: error image             .fit() //             .into(view);      return view; }  @override public int getcount() {     return arraylist.size(); }  @override public hashmap<string,string> getitem(int position) {     //return urls.get(position);     return arraylist.get(position); }  @override public long getitemid(int position) {     return position; } 

and link github project https://github.com/jess-anders/two-way-gridview

edit: little bit more information. played round little bit more , while no images shown in portrait, appear when rotate device. maybe xml help.

<com.ryanjohnstone.gamediscovery.app.com.jess.ui.twowaygridview         xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:app="http://schemas.android.com/apk/res-auto"         android:background="#e8e8e8"         android:id="@+id/similar_games_grid_view"         android:layout_width="fill_parent"         android:layout_height="115dp"         app:cachecolorhint="#e8e8e8"         app:rowheight="80dp"         app:numcolumns="@integer/similar_column_count"         app:numrows="1"         app:verticalspacing="1dp"         app:horizontalspacing="1dp"         app:stretchmode="spacingwidthuniform"         app:scrolldirectionportrait="horizontal"         app:scrolldirectionlandscape="horizontal"         app:gravity="center"         android:layout_gravity="center_horizontal|bottom" /> 

edit 2: reason nothing showing in portrait need set columnwidth attribute. don't see why necessary when have number of columns set. isn't necessary on gridview. there way in xml set value screen width divided number of columns?

edit 3: setting app:stretchmode columnwidth has fixed issue in portrait mode, see images , fill row , column. i'm still having problem in landscape of them not filling. here's current xml:

<com.ryanjohnstone.gamediscovery.app.com.jess.ui.twowaygridview         xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:app="http://schemas.android.com/apk/res-auto"         android:background="#e8e8e8"         android:id="@+id/grid_view"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         app:cachecolorhint="#e8e8e8"         app:numcolumns= "@integer/column_count"         app:numrows="auto_fit"         app:verticalspacing="1dp"         app:horizontalspacing="1dp"         app:stretchmode="columnwidth"         app:scrolldirectionportrait="vertical"         app:scrolldirectionlandscape="horizontal"         app:gravity="center"/> 

edit 4: clarify, it's working expected in portrait vertical scrolling. portrait horizontal scrolling isn't working how i'd like. shows images instead of number put in numcolumns.

edit 5: copied , pasted xml sample application of git hub project , works expected, i'm believing problem lies within adapter.

i resolved

xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:app="http://schemas.android.com/apk/res-auto" android:background="#e8e8e8" android:id="@+id/gridview" android:layout_width="fill_parent"  android:layout_height="fill_parent" app:cachecolorhint="#e8e8e8"  app:numcolumns="auto_fit" app:numrows="1"  app:stretchmode="columnwidth" app:scrolldirectionportrait="vertical" app:scrolldirectionlandscape="horizontal" app:gravity="center"  

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -