Android table effect-the row-changing feature of listview

Source: Internet
Author: User

First, inherit simpleadapter

 
Package meetweb.net. util; import Java. util. list; import Java. util. map; import android. content. context; import android. graphics. color; import android. view. view; import android. view. viewgroup; import android. widget. simpleadapter; public class specialadapter extends simpleadapter {private int [] colors = new int [] {0x30ff0000, 0x300000ff}; // It is not referenced here for use, just simple reference Array Operation Public specialadapter (context, list <? Extends Map <string,?> Data, int resource, string [] From, int [] to) {super (context, Data, resource, from, to) ;}@ overridepublic view getview (INT position, view convertview, viewgroup parent) {view = super. getview (Position, convertview, parent); int colorpos = position % colors. length; If (colorpos = 1) view. setbackgroundcolor (color. argb (250,255,255,255); // color setting elseview. setbackgroundcolor (color. argb (255,224,243,250); // color settings
 
Return view ;}}

Second, use the overloaded adapter to achieve the effect.

Import meetweb.net. util. specialadapter;
.....

Private specialadapter simpleadapter = NULL;

Public void showdata (){
Ratelist = rateservice. findall ();
System. Out. println (ratelist );
Lvrate = (listview) This. findviewbyid (R. Id. lvrate );
Simpleadapter = new specialadapter (this, ratelist, R. layout. accuratelistitem, new string [] {"yearlimit", "year1", "year2 "},
New int [] {R. Id. TV _yearlimit, R. Id. TV _year1, R. Id. TV _year2 });
Lvrate. setadapter (simpleadapter );
// Listview. setonitemclicklistener (listener );
}

 

In fact, we mainly need to reload simpleadapter. I reference the network point of view for writing.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.