i want to get the different colors in each row of the list view
but current only one color is shown
so how can i do this
ArrayAdapter<String> adapter=new ArrayAdapter<String(this,R.layout.latesthappenings,R.id.LH_Titles,titles);
setListAdapter(adapter);
i want to different color in each row
please tell how can i do
thanks
You can use anonymous ArrayAdapter
you have to write code inside getView()
ArrayAdapter<String> adapter=new ArrayAdapter<String>(
this,R.layout.main,R.id.textview1,titles){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(position ==condition){
convertView.setBackgroundResource(R.color.grey);}
else if(second condition){convertView.setBackgroundResource(R.color.something else);}
return view;};
};
ANother approach is
Why donot you do for Customized ListView? You can manage view as per your requirement there.
Have a Custom ArrayAdapter
Thanks Deepak
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With