I have a ListView with an arrayadapter. for some reason when i scroll the list i get this shadow and when i stop its ok. thats my code:
public class MobileArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] values;
public MobileArrayAdapter(Context context, String[] values) {
super(context, R.layout.listview, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.listview, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
textView.setText(values[position]);
if(textView.getText() == "royi"){
textView.setBackgroundColor(Color.GRAY);
}else{
textView.setBackgroundColor(Color.BLACK);
}
// Change icon based on name
String s = values[position];
System.out.println(s);
return rowView;
}
}
public class Listwithbaseadapter extends ListActivity {
static final String[] MOBILE_OS =
new String[] { "Android", "iOS", "royi", "Blackberry", "Android", "iOS", "royi", "Blackberry", "Android", "iOS", "royi", "Blackberry", "Android", "iOS", "royi", "Blackberry",
"Android", "iOS", "royi", "Blackberry", "Android", "iOS","Android", "iOS", "royi", "Blackberry", "Android", "iOS"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new MobileArrayAdapter(this, MOBILE_OS));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
//get selected items
String selectedValue = (String) getListAdapter().getItem(position);
Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();
}}
why is it happening and who can i fix it? Thanks!