Styling added rows to ArrayAdapter ListView Android?

What you have to do is creating a custom ArrayAdapter and override the getView() method. There you can decide whether apply a different style to the row or not. For instance: class CustomArrayAdapter extends ArrayAdapter { CustomArrayAdapter() { super(YourActivity.

This, R.layout. Message); } public View getView(int position, View convertView, ViewGroup parent) { View row=convertView; if (row==null) { LayoutInflater inflater=getLayoutInflater(); row=inflater. Inflate(R.layout.

Message, parent, false); } // e.g. If you have a TextView called in your row with ID 'label' TextView label=(TextView)row. FindViewById(R.id. Label); label.

SetText(itemsposition); // check the state of the row maybe using the variable 'position' if( I do not actually know whats your criteria to change style ){ label. SetTextColor(blablabla); } return(row); } }.

Thanks, Works like a charm after som tweaking! – James Ford Jul 15 '10 at 13:52 Having some new problem with this. Label.setTextColor() gets the whole label and sets the color for every row.It should just set the color on the new row, not on items already in the list.

– James Ford Jul 15 '10 at 16:10.

I have a ListView that I want to use with an ArrayAdapter to add different styled rows. The rows are created on different states in my application, and depending on the different states the rows should be styled(like colors and stuff). This works fine, messages are popping up in the list depending on different states, but I want to have the rows styled differently.

How to do this? Is the solution to create a custom ArrayAdapter with a custom Add() method?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions