Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple calling of getView() in GridView
    text
    copied!<p>My Activity consists of GridView which holds 40+ elements. After starting activity user could see maximum 15 items (3 rows, 5 items in each row). I wrote in getView() body to pass to the LogCat number of getting View:</p> <pre><code>Log.i("getView()", "GETTING VIEW_POSITION[" + String.valueOf(position) + "]" + (convertView != null?convertView.toString():"null")); </code></pre> <p>After launching my app I get such log:</p> <pre><code>02-09 14:34:56.900: INFO/getView()(388): GETTING VIEW_POSITION[0]null 02-09 14:34:57.300: INFO/getView()(388): GETTING VIEW_POSITION[0]android.widget.FrameLayout@44c7a9c0 02-09 14:34:57.300: INFO/getView()(388): GETTING VIEW_POSITION[1]null 02-09 14:34:57.400: INFO/getView()(388): GETTING VIEW_POSITION[2]null 02-09 14:34:57.510: INFO/getView()(388): GETTING VIEW_POSITION[3]null 02-09 14:34:57.620: INFO/getView()(388): GETTING VIEW_POSITION[4]null 02-09 14:34:57.720: INFO/getView()(388): GETTING VIEW_POSITION[5]null 02-09 14:34:57.840: INFO/getView()(388): GETTING VIEW_POSITION[6]null 02-09 14:34:57.930: INFO/getView()(388): GETTING VIEW_POSITION[7]null 02-09 14:34:58.273: DEBUG/dalvikvm(388): GC freed 3530 objects / 322744 bytes in 270ms 02-09 14:34:58.280: INFO/getView()(388): GETTING VIEW_POSITION[8]null 02-09 14:34:58.300: INFO/getView()(388): GETTING VIEW_POSITION[9]null 02-09 14:34:58.320: INFO/getView()(388): GETTING VIEW_POSITION[10]null 02-09 14:34:58.340: INFO/getView()(388): GETTING VIEW_POSITION[11]null 02-09 14:34:58.360: INFO/getView()(388): GETTING VIEW_POSITION[12]null 02-09 14:34:58.380: INFO/getView()(388): GETTING VIEW_POSITION[13]null 02-09 14:34:58.400: INFO/getView()(388): GETTING VIEW_POSITION[14]null 02-09 14:34:59.220: INFO/getView()(388): GETTING VIEW_POSITION[0]null 02-09 14:34:59.490: INFO/getView()(388): GETTING VIEW_POSITION[0]android.widget.FrameLayout@44c69ef0 </code></pre> <p>I also red <a href="http://code.google.com/p/android/issues/detail?id=12889">this</a> post about such kind of issue. But My GridView's height in XML description set as fill parent:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/grid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="auto_fit" android:horizontalSpacing="10dp" android:verticalSpacing="10dp" android:columnWidth="140dp" android:gravity="center" android:scrollbars="none" /&gt; </code></pre> <p>And finally to remove all doubts, here is my Adapter code:</p> <pre><code>public class ImageAdapter extends BaseAdapter { private Activity activity; private LayoutInflater inflater = null; private ArrayList&lt;Photo&gt; photoes; public ImageAdapter(Activity a, ArrayList&lt;Photo&gt; pictures) { photoes = pictures; activity = a; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public View getView(int position, View convertView, ViewGroup parent) { Log.i("getView()", "GETTING VIEW_POSITION[" + String.valueOf(position) + "]" + (convertView != null?convertView.toString():"null")); View mViewSlice = convertView; if(convertView == null) { mViewSlice = inflater.inflate(R.layout.photo_preview, null); ((TextView) mViewSlice.findViewById(R.id.name_of_photo)).setText(photoes.get(position).getName()); mViewSlice.setPadding(5, 5, 5, 5); mViewSlice.setLayoutParams(new GridView.LayoutParams(-2, -2)); } return mViewSlice; } @Override public int getCount() { return photoes.size(); } @Override public Object getItem(int position) { return photoes.get(position); } @Override public long getItemId(int position) { return position; } } </code></pre> <p>I hope somebody will respond at my problem and will help me to solve it.</p> <p>Waiting for your suggestions. Alex.</p>
 

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