Android Table effect--listview interlaced color

Source: Internet
Author: User

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);}
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};//There is no reference to use, just a simple reference array operation     public specialadapter (Context  context, List<? extends Map<String, ?>> data,             int resource, string[] from, int[]  to)  {        super (context, data, resource,  From, to);             }           @Override     public view getview (int position ,view  Convertview,viewgroup parent) {        view view= Super.getview (position, convertview, parent);         int  colorpos=position%colors.length;        if (colorPos==1)                 view.setbackgroundcolor ( Color.argb (250, 255, 255, 255))  //color Settings          Else            view.setbackgroundcolor (Color.argb (255, 224, 243, 250)); /color setting return view; } }


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.