You override getView in your adapter to make changes to the view. Keep in mind that ListView reuses the view implementations, so if you change the color to item 10, make sure you set the color to the opposite for all other views e. G new SimpleAdapter( ... ) { @Override public View getView (int position, View convertView, ViewGroup parent) { View view = super.
GetView(position, convertView, parent); if (position == 10) { // set background color = red; } else { // set background color = green; } return view; } }.
You override getView in your adapter to make changes to the view. Keep in mind that ListView reuses the view implementations, so if you change the color to item 10, make sure you set the color to the opposite for all other views. E.g.
New SimpleAdapter( ... ) { @Override public View getView (int position, View convertView, ViewGroup parent) { View view = super. GetView(position, convertView, parent); if (position == 10) { // set background color = red; } else { // set background color = green; } return view; } }.
Thanks a lot, SOLVED – Peter O. Nov 21 '10 at 11:24.
To accomplish this, you need to create a custom array adapter and then change the background color if the conditions are right. Check out this post for an example: Custom ArrayAdapter setBackground in getView.
Thanks a lot, greate tutorial, but I've used the one below – Peter O. Nov 21 '10 at 11:24.
Here is the code, hope it'll be helpful for other users private void fillData() { Cursor c = this.mDbManager. GetNgOrderDetailByOrderNumber(this. MNumber); ArrayList> items = new ArrayList>(); if (!c.isAfterLast()) { do { // ... filling HashMap and putting it to ArrayList } while (c.moveToNext()); } SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.
List_item, new String { "product", "ordered", "price", "discount" }, new int { R.id. ProductTextView, R.id. OrderedTextView, R.id.
PriceTextView, R.id. DiscountTextView }) { // here is the method you need to override, to achieve colorful list @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super. GetView(position, convertView, parent); HashMap items = (HashMap) getListView() .
GetItemAtPosition(position); if (Long. ParseLong(items. Get("id")) % 10 == 0) { view.
SetBackgroundColor(Color. GREEN); } else { view. SetBackgroundColor(Color.
YELLOW); } return view; } }; ListView l = (ListView) findViewById(android. R.id. List); l.
SetAdapter(adapter); }.
Keep in mind that ListView reuses the view implementations, so if you change the color to item 10, make sure you set the color to the opposite for all other views. View view = super. To accomplish this, you need to create a custom array adapter and then change the background color if the conditions are right.
Cursor c = this.mDbManager. SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout. New int { R.id.
View view = super. ListView l = (ListView) findViewById(android. Not the answer you're looking for?
Or ask your own question.
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.