Hi, I have a ListView with 4 rows and I want to color the text inside
each row when a row is clicked, the code below works fine but if I
change the selection mode of the ListView to single mode the View
object received is not the correct one. In this case :
if I click row number 1 it colors the 4th
if I click row number 2 it colors the 3th
if I click row number 3 it colors the second
if I click row number 4 it colors the first

Any idea about waht is happening???

@Override
    protected void onListItemClick(ListView listView, View v, int
position, long id) {

        super.onListItemClick(listView, v, position,
id);

        //This loop works fine
        //Clean the text color of all rows
        for (int conta = 0; conta <  (listView.getCount() ); conta ++)
{

                View objView = listView.getChildAt(conta);

                if (objView != null) {
                    TextView tvLetraRespuesta = (TextView)
objView.findViewById(R.id.tvLetraRespuesta);
                    tvLetraRespuesta.setTextColor(0xFFDDDDDD); //default
color
                }
        }

        //This piece of code gets wrong in single mode
        //Set the text color for the selected row
        TextView tvLetraRespuesta = (TextView)
v.findViewById(R.id.tvLetraRespuesta);        //here is the problem?
        if (tvLetraRespuesta != null) {
                tvLetraRespuesta.setTextColor(0xFF000000); //Row selected
text color
        }

    }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to