I have a listview with a custom arrayadapter that handles about 15 strings. The style of each row alternates (between labels and values for those labels--for example row 1 could be "email address" and row 2 would be the actual email address). I'm changing the style of each row to alternate like this in the arrayadapter's getView() method. So if the item at the current position is a label, I'll change the styling from the default row style (which is what the values have applied to them). When the listview first loads, the styling is perfect and just how I want it to be. If I scroll the list slowly up or down, it stays that way. However, if I scroll the list fast up and down, the styling of the value rows starts changing to that of the label ones until all of the rows have the styling of a label row. Does anyone know why this would be happening? I've used custom adapters on other listviews in the app with no problems like this.
Edit: Found out that it also changes all of the rows to the label styling on portrait->landscape orientation changes. Doesn't do this on landscape->portrait changes. Below is the adapter I'm using. Am I missing something?
public class DetailsAdapter extends ArrayAdapter<String> {
private TextView text = null;
private String item = null;
public DetailsAdapter(Context context, int resource, int textViewResourceId, String[] objects) {
super(context, resource, textViewResourceId, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
text = (TextView) super.getView(position, convertView, parent);
item = getItem(position);
if (item.equals("Name") || item.equals("Mobile") || item.equals("Home") || item.equals("Email") || item.equals("Address")) {
text.setBackgroundColor(0xFF575757);
text.setTextSize(15);
text.setTypeface(null, Typeface.BOLD);
text.setPadding(8, 5, 0, 5);
} else {
text.setPadding(15, 15, 0, 15);
}
return text;
}
@Override
public boolean isEnabled(int position) {
item = getItem(position);
if (item.equals("Name") || item.equals("Mobile") || item.equals("Home") || item.equals("Email") || item.equals("Address")) {
return false;
} else {
return true;
}
}
}