Note that there are some explanatory texts on larger screens.

plurals
  1. POListView operation varying according to the android versions
    primarykey
    data
    text
    <p>I came across some odd problem which some how deals with android OS versions. My problem is that the following given code is working properly as I want in android version 4 but the same programme working in a reverse manner in android version 2.3</p> <p>public class FeturesList extends Activity {</p> <pre><code>ImageView imgFeture; ListView listview; ArrayList&lt;String&gt; values; CustomListAdapter adapter; public static boolean itemOnView = false; int tempPos; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fetures_list); listview = (ListView) findViewById(R.id.listView1); values=new ArrayList&lt;String&gt;(); values.add(" ESSENTIAL "); values.add(" EMERGENCY "); values.add(" ENTERTAINMENT "); values.add(" VIDEO CALL "); values.add(" DOCTORS "); values.add(" SOCIETY "); values.add(" FAMILY "); values.add(" OTHERS "); values.add(" WHAT'S NEW "); imgFeture = (ImageView) findViewById(R.id.imageFeatures); adapter = new CustomListAdapter(this, values); listview.setAdapter(adapter); listview.setSelection(0); listview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int position, long id) { imgFeture.setBackgroundDrawable(getResources().getDrawable(getResources().getIdentifier("drawable/feature_"+position,"drawable",getPackageName()))); tempPos = position; for(int i = 0; i &lt; arg0.getChildCount(); i++){ if(i == position){ arg0.getChildAt(i).setBackgroundColor(Color.WHITE); TextView text = (TextView) v.findViewById(R.id.rowListTextView); text.setTextColor(Color.BLACK); adapter.notifyDataSetChanged(); }else{ arg0.getChildAt(i).setBackgroundColor(Color.MAGENTA); } } } }); } public class CustomListAdapter extends ArrayAdapter&lt;String&gt; { Activity context; ArrayList&lt;String&gt; row=null; LayoutInflater inflator=null; public CustomListAdapter(Activity context,ArrayList&lt;String&gt; row) { super(context,R.layout.listrow,row); this.context=context; this.row=row; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub View rowView=convertView; /*FilterItem item = (FilterItem)this.getItem(position);*/ if(convertView==null) { inflator=context.getLayoutInflater(); final ViewHolder holder=new ViewHolder(); rowView=inflator.inflate(R.layout.listrow, null); holder.rowText=(TextView)rowView.findViewById(R.id.rowListTextView); rowView.setTag(holder); } final ViewHolder hold=(ViewHolder)rowView.getTag(); hold.rowText.setText(row.get(position)); if(tempPos != position){ hold.rowText.setTextColor(Color.WHITE); } return rowView; } } static class ViewHolder { TextView rowText; } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_fetures_list, menu); return false; } @Override public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); overridePendingTransition(R.anim.slide_out_left,R.anim.slide_out_right); this.finish(); } </code></pre> <p>In android 4.0 the variable "position" of setOnItemClickListener() is working proper i.e if I click on 0 or 1 or 2 than it showing proper position as 0, 1, or 2 respectivily but the same thing is working reverse in android 2.3 as for position 0 it is taking position as 8 like 0-8, 1-7, 2-5, 4-4, 5-4 and so on... Please suggest me how to overcome this.</p>
    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