Some of the most recent business cards clip the app. One of the business card holder customer requirements to make collapsible telescopic effect, really cost a great effort AH ~ ~ ~ Nothing to say to see ~ ~
Package Com.cards.activity;import Java.util.arraylist;import Java.util.hashmap;import java.util.List;import Java.util.map;import Android.app.listactivity;import Android.content.context;import Android.graphics.Color;import Android.os.bundle;import Android.util.log;import Android.view.layoutinflater;import Android.view.View;import Android.view.viewgroup;import Android.widget.abslistview;import Android.widget.AbsListView.OnScrollListener; Import Android.widget.adapterview;import Android.widget.adapterview.onitemclicklistener;import Android.widget.baseadapter;import Android.widget.linearlayout;import Android.widget.relativelayout;import Android.widget.textview;import Com.cards.r;public class Cardslistact extends Listactivity implements Onscrolllistener , Onitemclicklistener {private static String Layout_inflater_service = Context.layout_inflater_service;public static Final string tv_cards_name = "Tv_cards_name";p ublic static final String tv_cards_phonenuminfo = "Tv_cards_phonenuminfo"; PublicStatic final String tv_cards_addressinfo = "Tv_cards_addressinfo";p ublic static final String tv_cards_mailinfo = "Tv_card S_mailinfo ";p ublic static final String tv_cards_otherinfo =" Tv_cards_otherinfo ";p ublic static final string tv_card_name = "Tv_card_name";p rivate layoutinflater minflater;private flexlistadapter adapter;private List<Map<String, String>> contentdefilelist;private boolean[] iscurrentitems;protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); minflater = (Layoutinflater) this.getsystemservice (LAYOUT_INFLATER_SERVICE); Init (); Setlistadapter (adapter); Getlistview (). SetBackgroundColor (Color.White); Getlistview (). Setcachecolorhint ( color.transparent); Getlistview (). Setdivider (Getresources (). getdrawable (R.color.transparent)); GetListView (). Setselector (R.DRAWABLE.WORK_DETAIL_CLICK_BG); Getlistview (). Setonscrolllistener (this); Getlistview (). Setonitemclicklistener (this);} /** * Initialize data */private void init () {contentdefilelist = new arraylist< Map<string, string>> (); map<string, string> contentdefile = new hashmap<string, string> (); Contentdefile.put (TV_CARDS_NAME, "Zhang San"); Contentdefile.put (Tv_card_name, "Zhang San"); Contentdefile.put (Tv_cards_phonenuminfo, "13933333333"); ContentDefile.put ( Tv_cards_addressinfo, "No. No. 866 Chaoyang North Street, Baoding High open area (south of Bao Bai shopping Plaza)"; Contentdefile.put (Tv_cards_mailinfo, "[email protected]" ); Contentdefile.put (Tv_cards_otherinfo, "department manager"); map<string, string> contentdefile_1 = new hashmap<string, string> (); Contentdefile_1.put (TV_CARDS_NAME, " John Doe "); Contentdefile_1.put (Tv_card_name," John Doe "); Contentdefile_1.put (Tv_cards_phonenuminfo," 13933333333 "); Contentdefile_1.put (Tv_cards_addressinfo, "No. No. 866 Chaoyang North Street, Baoding High-open area (south of Bao Bai Shopping Plaza)"); Contentdefile_1.put (Tv_cards_mailinfo, "[ Email protected] Contentdefile_1.put (tv_cards_otherinfo, "Manager"); map<string, string> contentdefile_2 = new hashmap<string, string> (); Contentdefile_2.put (TV_CARDS_NAME, " Harry "); Contentdefile_2.put (Tv_card_name," Harry "); contentdefile_2.Put (Tv_cards_phonenuminfo, "13933333333"); Contentdefile_2.put (Tv_cards_addressinfo, "HFDKAJSHFKADSJFLKAJSDLKF"); Contentdefile_2.put (Tv_cards_mailinfo, "[email protected]"); Contentdefile_2.put (TV_CARDS_OTHERINFO, "Manager"); map<string, string> contentdefile_3 = new hashmap<string, string> (); Contentdefile_3.put (TV_CARDS_NAME, " VVV "); Contentdefile_3.put (Tv_card_name," VVV "); Contentdefile_3.put (Tv_cards_phonenuminfo," 13933333333 "); Contentdefile_3.put (Tv_cards_addressinfo, "HFDKAJSHFKADSJFLKAJSDLKF"); Contentdefile_3.put (TV_CARDS_MAILINFO, "[ Email protected]); Contentdefile_3.put (Tv_cards_otherinfo, "designer"); map<string, string> contentdefile_5 = new hashmap<string, string> (); Contentdefile_5.put (TV_CARDS_NAME, " BBB "); map<string, string> contentdefile_6 = new hashmap<string, string> (); Contentdefile_6.put (TV_CARDS_NAME, " CCC "); Contentdefile_6.put (Tv_card_name," CCC "); map<string, string> contentdefile_7 = new hashmap<string, string> (); contentdeFile_7.put (Tv_cards_name, "ddd"); Contentdefile_7.put (Tv_card_name, "ddd"); map<string, string> contentdefile_4 = new hashmap<string, string> (); Contentdefile_4.put (TV_CARDS_NAME, " AAA "); Contentdefile_4.put (Tv_card_name," AAA "); Contentdefilelist.add (contentdefile); Contentdefilelist.add ( Contentdefile_1); Contentdefilelist.add (contentdefile_2); Contentdefilelist.add (contentdefile_3); Contentdefilelist.add (Contentdefile_4); Contentdefilelist.add (contentdefile_6); Contentdefilelist.add ( contentdefile_7) Iscurrentitems = new Boolean[contentdefilelist.size ()];for (int i = 0; i < iscurrentitems.length; i++ {Iscurrentitems[i] = false;} LOG.W ("TAG", "autoloadactivity init () =========>>>>>> come in."); adapter = new Flexlistadapter ();} public void Onscroll (Abslistview V, int. I, int j, int k) {}public void onscrollstatechanged (Abslistview v, int state) {if (state = = Onscrolllistener.scroll_state_idle) {}} @Overridepublic void Onitemclick (adapterview<?> parent, view view, int Position,long id) {if (Iscurrentitems[position]) {iscurrentitems[position] = false;} else {iscurrentitems[position ] = true;} Instant refresh of Adapter.notifydatasetchanged ();} Class Flexlistadapter extends Baseadapter {int count = Contentdefilelist.size ();p ublic int GetCount () {return count;} Public Object getItem (int pos) {return pos;} public long Getitemid (int pos) {return pos;} Public View getView (int pos, view V, ViewGroup p) {flexlinearlayout view = null;if (null = = v) {view = new flexlinearlayou T (Cardslistact.this,contentdefilelist.get (POS), POS, false);} else {view = (flexlinearlayout) v;view.setworktitlelayout (Contentdefilelist.get (POS), Pos,iscurrentitems[pos]);} return view;}} public class Flexlinearlayout extends LinearLayout {public static final int BULE = 0xff3d8cb8;private linearlayout layout; Private Relativelayout rlname;private relativelayout llcards;private TextView tvcardsphonenuminfo;private TextView Tvcardsaddressinfo;private TextView tvcardsmailinfo;private TextView TvcardsothErinfo;private TextView tvcardsname;private TextView tvcardname;/** * Create a linearlayout with scaling effect * * @param context * @param Contextdefail * Content Details * @param position * location of the list where the column is located * @param iscurrentitem * is the extension */publ IC flexlinearlayout (Context context,final map<string, string> contextdefail, final int Position,boolean Iscurrentitem) {super (context); layout = (LinearLayout) minflater.inflate (r.layout.act_cards_list,null); rlname = ( Relativelayout) Layout.findviewbyid (r.id.rl_name); llcards = (relativelayout) Layout.findviewbyid (R.id.ll_cards); Tvcardsphonenuminfo = (TextView) Layout.findviewbyid (r.id.tv_cards_phonenuminfo); tvcardsname = (TextView) Layout.findviewbyid (r.id.tv_cards_name); tvcardname = (TextView) Layout.findviewbyid (r.id.tv_card_name); Tvcardsaddressinfo = (TextView) Layout.findviewbyid (r.id.tv_cards_addressinfo); tvcardsmailinfo = (TextView) Layout.findviewbyid (r.id.tv_cards_mailinfo); tvcardsotherinfo = (TextView) Layout.findviewbyid (R.id.tv_caRds_otherinfo); This.addview (layout); Setworktitlelayout (contextdefail, Position, Iscurrentitem);} /** * Set the status and style of the column * * @param contentdefail * Content Details * @param position * location of the list of the column * @param iscurrentit EM * Whether to stretch */public void Setworktitlelayout (Final map<string, string> contentdefail,final int position, b Oolean iscurrentitem) {rlname.setbackgroundresource (position% 2 = = 1)? r.drawable.title_1:r.drawable.title_2); Tvcardsname.settext (Contentdefail.get (tv_cards_name)); Tvcardsname.settextcolor ((position% 2 = = 0)? BULE:Color.WHITE), if (Iscurrentitem) {log.d ("TAG", "Iscurrentitem ============>>>>>>>>> "+ position"); Tvcardsphonenuminfo.settext ("Tel:" + contentdefail.get (tv_cards_phonenuminfo)); Tvcardsmailinfo.settext ("e-mail:" + contentdefail.get (tv_cards_mailinfo)); Tvcardsaddressinfo.settext ("Address:" + Contentdefail.get (Tv_cards_addressinfo)); Tvcardsotherinfo.settext (Contentdefail.get (TV_CARDS_OTHERINFO)); Tvcardname.settext (contentdeFail.get (Tv_card_name));} Llcards.setvisibility (Iscurrentitem? Visible:gone);}}}
Act_cards_list Layout file:
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" wrap_content "android:orientation=" vertical "& Gt <relativelayout android:id= "@+id/rl_name" android:layout_width= "Fill_parent" android:layout_height = "Wrap_content" android:background= "@color/transparent" > <textview android:id= "@+id/tv_car Ds_name "style=" @style/cards_item_title "android:text=" passers-by "/> </RelativeLayout> < Relativelayout android:id= "@+id/ll_cards" android:layout_width= "Fill_parent" android:layout_height= "W Rap_content "android:background=" @drawable/iv_card_list_bg "android:orientation=" vertical "> <l Inearlayout android:id= "@+id/ll_cards_name" android:layout_width= "Wrap_content" android:l ayout_height= "Wrap_content" android:layout_margintop= "20dip" > <textview android:id= "@+id/tv_card_name" style= "@style/work_detail_row_style" android:text= "passers-by" android:textsize= "15SP" android:textstyle= "Bold"/> <textview android:id= "@+id/tv_mc_otherinfo" style= "@style/work_detail_row_style" android:text= "financial Director" android:textcolor= "@col Or/blue "android:textsize=" 10DP "/> </LinearLayout> <linearlayout Android Oid:id= "@+id/ll_cards_info" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:layout_below= "@+id/ll_cards_name" android:orientation= "vertical" android:layout _margintop= "20DP" > <textview android:id= "@+id/tv_mc_phonenum" style= "@style /work_detail_row_style " android:text= "18933333333"/> <textview android:id= "@+id/tv_mc_mail" style= "@style/work_detail_row_style" android:text= "[email protected]"/> <te Xtview android:id= "@+id/tv_mc_addressinfo" style= "@style/work_detail_row_style" Android:layout_width= "171DP" android:layout_centerinparent= "true" android:text= "Baoding high open area Chaoyang North No. 866 Avenue (south of Bao Bai shopping Plaza) "/> </LinearLayout></RelativeLayout></LinearLayout>
Zhao Yazhi _androidui_android Folding telescopic imitation accordion effect in the ListView (Static)