Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to stop drawing GridView items BEFORE the parent View becomes scrollable?
    text
    copied!<p>I'm trying to populate a <code>ViewFlipper</code> with a <code>GridView</code>, but with a paging capability rather than scrolling. The <code>GridView</code> will fill out a single "page" (one complete page without scrolling), and start filling out the next View in the <code>ViewFlipper</code> with the next bit of the data set.</p> <p>I need to dynamically fill the pages, as the screen sizes will vary. This <code>GridView</code> sports a custom adapter class with a <code>getView()</code> override, so I was thinking the most elegant solution would be to draw the view as normal in the <code>GridView</code>, but this is where I run into some confusion:</p> <p>Two things:</p> <p>How can i tell the <code>getView()</code> function to write the <code>GridView</code> items to the next <code>View</code> in the <code>ViewFlipper</code>? And by that token, how can I know when the screen fills to just before the scroll bar pops up (I don't want scrollable lists, which was the whole point in using a <code>ViewFlipper</code>).</p> <p>Or is there a better solution that i just haven't found yet? I couldn't find an example in the API demos and little info here on stackoverflow except this, which got me started, but I still need the above two suggestions to make this solution work (unless there's something better): <a href="https://stackoverflow.com/questions/5563749/android-viewflipper-not-flipping">Android ViewFlipper not flipping</a></p> <p>The GridView adapter:</p> <pre><code>// custom adapter made for the GridView public class ButtonAdapter extends BaseAdapter { private Context mContext; private List&lt;Map&lt;String, String&gt;&gt; mData; private int mLayout; public ButtonAdapter(Context c, int layout, List&lt;Map&lt;String, String&gt;&gt; list) { this.mContext = c; this.mData = list; this.mLayout=layout; } public int getCount() { return mData.size(); } public Object getItem(int position) { return mData.get(position); } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { Button btn = null; if(convertView==null) { convertView = inflater.inflate(this.mLayout, null); } btn = (Button)convertView.findViewById(R.id.grid_btn); if(btn != null) { //btn.setPadding(8,8,8,8); btn.setText(mData.get(position).get("label")); btn.setId(position); } return convertView; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload