Android Wear Control--wearablelistview (demo included)

Source: Internet
Author: User
Tags getcolor

Wearablelistview is a widget for Android small devices such as smart watch display list, can be village scrolling, very handy to display list controls on only watches, each showing three lists in the middle of the screen.

It inherits the Recyclerview and implements the Onscrolllistener interface.

public class Wearablelistview extends Android.support.v7.widget.RecyclerView           implements Android.support.v7.widget.RecyclerView.OnScrollListener {    ...  }
Here are examples of use


Package Com.technotalkative.wearablelistviewdemo; Import Android.app.activity;import Android.content.context;import Android.os.bundle;import Android.support.wearable.view.watchviewstub;import Android.support.wearable.view.wearablelistview;import Android.view.layoutinflater;import Android.view.viewgroup;import Android.widget.TextView; Import java.util.ArrayList; public class Simplelistactivity extends Activity implements wearablelistview.clicklistener{private Wearablelistview m     ListView;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (r.layout.activity_my);        Final watchviewstub stub = (watchviewstub) Findviewbyid (r.id.watch_view_stub); Stub.setonlayoutinflatedlistener (New Watchviewstub.onlayoutinflatedlistener () {@Override public voi          D onlayoutinflated (watchviewstub stub) {Mlistview = (Wearablelistview) Stub.findviewbyid (R.ID.LISTVIEW1);      Mlistview.setadapter (New Myadapter (Simplelistactivity.this));            Mlistview.setclicklistener (Simplelistactivity.this);    }        });    } private static arraylist<string> listItems;        static {ListItems = new arraylist<string> ();        Listitems.add ("Monday");        Listitems.add ("Tuesday");        Listitems.add ("Wednesday");        Listitems.add ("Thursday");        Listitems.add ("Friday");    Listitems.add ("Saturday"); } @Override public void OnClick (Wearablelistview.viewholder viewholder) {} @Override public void Ontope Mptyregionclick () {} private class Myadapter extends Wearablelistview.adapter {private final Layoutinflat         ER minflater;        Private Myadapter (Context context) {Minflater = Layoutinflater.from (context);            } @Override Public Wearablelistview.viewholder oncreateviewholder (viewgroup parent, int viewtype) { return new Wearablelistview.        Viewholder (minflater.inflate (r.layout.row_simple_item_layout, null)); } @Override public void Onbindviewholder (wearablelistview.viewholder holder, int position) {Tex            TView view = (TextView) holder.itemView.findViewById (R.id.textview);            View.settext (Listitems.get (position). ToString ());        Holder.itemView.setTag (position);        } @Override public int getitemcount () {return listitems.size (); }    }}


You can add icons to the list to make it more beautiful


Private Final class Myitemview extends Framelayout implements Wearablelistview.item {final Circledimageview Imgvi        ew        Final TextView Txtview;        private float Mscale;        private final int mfadedcirclecolor;         private final int mchosencirclecolor;            Public Myitemview (Context context) {super (context);            View.inflate (context, r.layout.row_advanced_item_layout, this);            Imgview = (Circledimageview) Findviewbyid (r.id.image);            Txtview = (TextView) Findviewbyid (R.id.text); Mfadedcirclecolor = Getresources (). GetColor (Android.            R.color.darker_gray); Mchosencirclecolor = Getresources (). GetColor (Android.        R.color.holo_blue_dark);        } @Override Public Float Getproximityminvalue () {return mdefaultcircleradius;        } @Override Public Float Getproximitymaxvalue () {return mselectedcircleradius; } @Override Public Float GetcurrenTproximityvalue () {return mscale;            } @Override public void Setscalinganimatorvalue (float value) {mscale = value;            Imgview.setcircleradius (Mscale);        Imgview.setcircleradiuspressed (Mscale);            } @Override public void Onscaleupstart () {Imgview.setalpha (1f);            Txtview.setalpha (1f);        Imgview.setcirclecolor (Mchosencirclecolor);            } @Override public void Onscaledownstart () {imgview.setalpha (0.5f);            Txtview.setalpha (0.5f);        Imgview.setcirclecolor (Mfadedcirclecolor); }    }

The following connection is the complete project of the demo Wearablelistview demo




Android Wear Control--wearablelistview (demo included)

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.