Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid notifydatasetchange() creates new view while needed update in view with layout position maintain
    primarykey
    data
    text
    <p>I have made listview with horizontalView. In this each position of ListView contains HorizontalView in which there is set of images which can scroll Horizontally.</p> <p>Whenever List reaches to its end while scrolling vertically, i call notifydatasetchange() method of listview, which interns creates new view of list. </p> <p>My List view is like this </p> <p><img src="https://i.stack.imgur.com/TRJ5L.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/mlSjd.png" alt="enter image description here"></p> <p><strong>My problem</strong> is that :</p> <p>Suppose i am at image 12 of Horizontal view at position 0 of ListView. When notifydatasetchange() calls it automatically refreshes all view and Image position becomes 0 at position 0 of ListView. </p> <p>It can be irritating for user to scroll again &amp; again for specific image.</p> <p>I need to maintain position of Images on view so when it will reload it automatically show as it was before calling notifydatasetchange().</p> <p><strong>Note :</strong> I am using two adapters to populate Horizontal scrollView in ListView.</p> <p><strong>Adapter 1</strong> </p> <pre><code> private class MyAdapter extends BaseAdapter { private Context context; private Activity activity; private int count_processed_rows = 0; MyAdapter(Activity activity, Context context) { this.context = context; this.activity = activity; } @Override public int getCount() { // TODO Auto-generated method stub int size = 0; if((al_thumb_images != null) &amp;&amp; (al_thumb_images.size() &gt; 0)){ size = (al_thumb_images.size() / 20) ; } return size; } @Override public Object getItem(int arg0) { // TODO Auto-generated method stub return arg0; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub //System.out.println("Parent position : "+position); ++count_processed_rows; int processed_row_limit = getCount() * 2; View row = convertView; ViewHolder holder = null; TextView textView_list_item = null; if (row == null) { holder = new ViewHolder(); LayoutInflater inflater_parent = this.activity.getLayoutInflater(); row = (View) inflater_parent.inflate(R.layout.listrow, null); holder.linear = (HorizontalView) row.findViewById(R.id.gallery); holder.linear.setId(position); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } try{ HorizontalImageAdapter imageAdapter = new HorizontalImageAdapter(activity, context, position); holder.linear.setAdapter(imageAdapter); } catch(Exception e){ System.out.println("catch :: "+e); } return row; } private class ViewHolder { private HorizontalView linear; } } </code></pre> <p><strong>Adapeter 2</strong> </p> <pre><code> private class HorizontalImageAdapter extends BaseAdapter { private Activity activity; private Context context; private int list_row; public HorizontalImageAdapter(Activity activity, Context context, int list_row) { System.out.println(111); this.activity = activity; this.context = context; this.list_row = list_row; } @Override public int getCount() { return 20; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(final int position, View convertView, ViewGroup parent) { System.out.println(112); View row = convertView; ViewHolder holder = null; if (row == null) { holder = new ViewHolder(); LayoutInflater inflater_child = this.activity.getLayoutInflater(); row = (View) inflater_child.inflate(R.layout.listitem, null, false); holder.image = (ImageView) row.findViewById(R.id.image); holder.progress = (ProgressBar) row.findViewById(R.id.progress); holder.checkBox_image = (CheckBox) row.findViewById(R.id.checkBox_image); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } try{ { int limit = ((this.list_row) * 20) + position; System.out.println(TAG+" --&gt; "+"position : "+position); System.out.println(TAG+" --&gt; "+"list_row : "+this.list_row); System.out.println(TAG+" --&gt; "+"limit : "+limit); System.out.println(TAG+" --&gt; "+" i : "+((this.list_row) * 20)); System.out.println(TAG+" --&gt; "+"al.size() : "+al_thumb_images.size()); int counter = 0; final String s_THUMB_IMAGE_URL = al_thumb_images.get(limit); counter++; aq.id(holder.image).progress(holder.progress).image(s_THUMB_IMAGE_URL, true, true, 500, R.drawable.ic_launcher); } } catch(Exception e){ System.out.println("catch :: "+e); } return row; } private class ViewHolder { ImageView image; ProgressBar progress; TextView icon_text; CheckBox checkBox_image; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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