In AndroidUI_Android, The listview can be scaled to simulate the accordion effect (static)

Source: Internet
Author: User

In AndroidUI_Android, The listview can be scaled to simulate the accordion effect (static)

The most recent apps with a name card. The customer of the name card holder needs to make a foldable scaling effect, which is really a great deal of effort ~~~ Let's not talk about anything ~~

 

 

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"; public static final String Signature = "signature"; public static final String TV _CARDS_ADDRESSINFO = "TV _cards_addressInfo "; public static final String comment = "TV _CARDS_MAILINFO"; public static final String comment = "comment"; public static final String TV _CARD_NAME = "TV _card_name"; private LayoutInflater mInflater; private FlexListAdapter adapter; private List
 
  
> 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
   
    
ContentDefile = new HashMap
    
     
(); 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. 866, Chaoyang North Street, Gaokai district, Baoding City (south of baobai shopping mall)"); contentDefile. put (TV _CARDS_MAILINFO, "1111@qq.com"); contentDefile. put (TV _CARDS_OTHERINFO, "department manager"); Map
     
      
ContentDefile_1 = new HashMap
      
        (); ContentDefile_1.put (TV _CARDS_NAME, ""); contentDefile_1.put (TV _CARD_NAME, ""); contentDefile_1.put (inputs, "13933333333"); contentDefile_1.put (inputs, "No. 866 Chaoyang North Street, Gaokai district, Baoding City (south of baobai shopping mall)"); contentDefile_1.put (TV _CARDS_MAILINFO, "1111@qq.com"); contentDefile_1.put (TV _CARDS_OTHERINFO, "manager"); Map
       
         ContentDefile_2 = new HashMap
        
          (); ContentDefile_2.put (TV _CARDS_NAME, ""); contentDefile_2.put (TV _CARD_NAME, ""); contents (outputs, "13933333333"); contentDefile_2.put (inputs, "inputs "); contentDefile_2.put (TV _CARDS_MAILINFO, "1111@qq.com"); contentDefile_2.put (TV _CARDS_OTHERINFO, "manager"); Map
         
           ContentDefile_3 = new HashMap
          
            (); ContentDefile_3.put (TV _CARDS_NAME, "vvv"); contentDefile_3.put (TV _CARD_NAME, "vvv"); values (outputs, "13933333333"); contentDefile_3.put (inputs, "inputs "); contentDefile_3.put (TV _CARDS_MAILINFO, "1111@qq.com"); contentDefile_3.put (TV _CARDS_OTHERINFO, "designer"); Map
           
             ContentDefile_5 = new HashMap
            
              (); ContentDefile_5.put (TV _CARDS_NAME, "bbb"); Map
             
               ContentDefile_6 = new HashMap
              
                (); ContentDefile_6.put (TV _CARDS_NAME, "ccc"); contentDefile_6.put (TV _CARD_NAME, "ccc"); Map
               
                 ContentDefile_7 = new HashMap
                
                  (); ContentDefile_7.put (TV _CARDS_NAME, "ddd"); contentDefile_7.put (TV _CARD_NAME, "ddd"); Map
                 
                   ContentDefile_4 = new HashMap
                  
                    (); 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 ;} // refresh the adapter instantly. policydatasetchanged ();} class FlexListAdapter extends BaseAdapter {int count = contentDefileList. size (); public 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 FlexLinearLayout (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 details; 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 * detailed content * @ param position * location of the column list * @ param isCurrentItem *? to stretch */public FlexLinearLayout (Context context, final Map
                   
                     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 column status and style ** @ param contentDefail * Details * @ param position * the position of the column's list * @ param isCurrentItem * Whether to stretch */ public void setWorkTitleLayout (final Map
                    
                      ContentDefail, final int position, boolean 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 ("Phone:" + contentDefail. get (TV _CARDS_PHONENUMINFO); tvCardsMailInfo. setText ("Email:" + 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:

 

 
     
          
       
   
      
          
               
                
             
     
    
           
               
                
                 
       
      
     
    
   
  
 


 

 

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.