Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Edit ArrayAdapter row inline
    text
    copied!<p>I have a ListActivity which uses an ArrayAdapter To display the rows. I want to edit the rows inline, to be precise I want to toggle the text in one of the Views when ever User Clicks on the View. Eg. If the TextView Value id "Complete" it will become "Incomplete" and Visa versa.</p> <p>But the problem is , the row tvstate value is <strong>always the value of the last row</strong> and not the one which is clicked.</p> <p>Am I missing something basic. Please help as I am very new to Android development.</p> <p>EDIT : Even a mechanism to Update the same row in the Adapter will be of help, if not inline edit.</p> <p>Here is my code for the Adapter.</p> <pre><code>public View getView(final int position, View convertView,final ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.rowlayout_cpe, null); } CPEDetails dt = items.get(position); if (dt != null) { tvSNo = (TextView) v.findViewById(R.id.serialNumber); tvState = (TextView) v.findViewById(R.id.state); if (tvSNo != null &amp;&amp; tvState != null) { tvSNo.setText(dt.getVc_serial()); tvState.setText(dt.getState()); } } tvState.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { tvState.setText(tvState.getText().toString().equalsIgnoreCase("Completed")?"Incomplete":"Completed"); Utility.i("On Click State ::"+position); CPEDetails cpe = new CPEDetails(); cpe.setVc_serial(tvSNo.getText().toString()); cpe.setState(tvState.getText().toString()); items.set(position, cpe); notifyDataSetChanged(); } }); btnDelete = (ImageButton) v.findViewById(R.id.btnDelete); btnDelete.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { items.remove(position); notifyDataSetChanged(); } }); return v; } </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