Android Pinnedsectionlistview Shrink

Source: Internet
Author: User

Open Source project: Https://github.com/beworker/pinned-section-listview, the project is using Arrayadapter (). Not very suitable for me, slightly modified, imitation of the interface

Pinnedsectionlistview modified a line of code, or will error, the code is as follows

void Createpinnedshadow (int position) {} "

if (Layoutparams = = null) {   //layoutparams = (layoutparams) generatedefaultlayoutparams (); layoutparams = new Layoutparams (Layoutparams.match_parent, layoutparams.wrap_content);    Pinnedview.setlayoutparams (layoutparams);}


:





Specific code Adapterlistview:

Package Pinneactivity.example.ui;import Java.util.arraylist;import Pinneactivity.example.ui.pinnedsectionlistview.pinnedsectionlistadapter;import Android.content.Context;import Android.view.layoutinflater;import Android.view.view;import Android.view.viewgroup;import Android.widget.baseadapter;import Android.widget.imageview;import android.widget.textview;/* * * * This is the company of Adapter * * @author Yangwenlong */public class Adapterlistview extends Baseadapter implements PINNEDSECTIONLISTADAPTER{PR Ivate arraylist<bean> list;private Context context;public arraylist<bean> getList () {return list;} public void setlist (arraylist<bean> list) {if (list!=null) {this.list = list;} Else{list=new arraylist<bean> ();}} Public Adapterlistview (Context context,arraylist<bean> list) {this.setlist (list); this.context=context;} @Overridepublic int GetCount () {//TODO auto-generated method Stubreturn list.size ();} @Overridepublic Bean getItem (int position) {//TODO auto-generated mEthod Stubreturn list.get (position);} @Overridepublic long Getitemid (int position) {//TODO auto-generated method Stubreturn position;} @Overridepublic view GetView (int position, view Converview, ViewGroup viewgrop) {//TODO auto-generated method Stubviewhol Der Vh=null;if (converview==null) {vh=new viewholder (); Converview=layoutinflater.from (context). Inflate ( R.layout.item, NULL); vh.company_item= (TextView) Converview.findviewbyid (r.id.title); vh.image= (ImageView) Converview.findviewbyid (R.id.imageview1); Converview.settag (VH);} Else{vh= (Viewholder) Converview.gettag ();} Bean Bean=getitem (position); Vh.company_item.setText (Bean.text); if (Bean.type = = bean.section) {Vh.company_ Item.setbackgroundresource (R.DRAWABLE.BAO_HEADVIEW_BG); vh.image.setVisibility (View.gone);} Else{vh.company_item.setbackgroundresource (R.DRAWABLE.DETAILS_LAYOUT_BG); vh.image.setVisibility (view.visible);} return Converview;} @Overridepublic boolean isitemviewtypepinned (int viewtype) {//TODO auto-generated method Stubreturn ViewtypE = = bean.section;//0 is the title, 1 is the content} @Overridepublic int Getviewtypecount () {return 2;//2 type of view Baseadapter method}@ overridepublic int Getitemviewtype (int position) {return (Bean) GetItem (position)). Type;        public void Refresh (arraylist<bean> arr) {setlist (arr);    Notifydatasetchanged (); }}

Headview:

Package Pinneactivity.example.ui;import Android.app.activity;import Android.view.view;import Android.view.view.onclicklistener;import android.widget.linearlayout;import android.widget.toast;/* * Fail View * * @ Author Yangwenlong */public class Headview implements Onclicklistener{private view view = Null;private Activity activity;p Rivate linearlayout newfriends;private linearlayout grop;private linearlayout tag;private LinearLayout publicNumber; private static Headview Headview = Null;public static Headview getinstance (activity activity) {Headview = new Headview (act ivity); return headview;} Public Headview (activity activity) {View=activity.getlayoutinflater (). Inflate (r.layout.item_head, NULL); this.activity=activity;}        Public Headview initialization () {newfriends= (linearlayout) View.findviewbyid (r.id.layout_new);        grop= (LinearLayout) View.findviewbyid (R.id.layout_group);        Tag= (LinearLayout) View.findviewbyid (R.id.layout_tag); Publicnumber= (LinearLayout) view.findviewbyiD (R.id.layout_public);        Newfriends.setonclicklistener (this);        Grop.setonclicklistener (this);        Tag.setonclicklistener (this); Publicnumber.setonclicklistener (this); return Headview;} Public View GetView () {return View;} @Overridepublic void OnClick (View v) {//TODO auto-generated method stubif (v==newfriends) {Toast.maketext (activity, "new friend ", Toast.length_short). Show ();} else if (v==grop) {Toast.maketext (activity, "group chat", Toast.length_short). Show (); else if (V==tag) {Toast.maketext (activity, "label", Toast.length_short). Show (); else if (v==publicnumber) {Toast.maketext (activity, "public number", Toast.length_short). Show ();}}

Project Download: http://download.csdn.net/detail/anddroid_lanyan/8252891


Android Pinnedsectionlistview Shrink

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.