Android Wear control-WearableListView (with Demo) and androidwear

Source: Internet
Author: User

Android Wear control-WearableListView (with Demo) and androidwear

WearableListView is a widget used to display the list of small android devices, such as smart watches. It can be scaled in a village. It is very convenient to display only the list controls on the watch. Each time, three lists are displayed in the middle of the screen.

It inherits RecyclerView and implements the OnScrollListener interface.

public class WearableListView extends android.support.v7.widget.RecyclerView           implements android.support.v7.widget.RecyclerView.OnScrollListener {    ….  ….}
The following is an example


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 mListView;     @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 void 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 onTopEmptyRegionClick() {     }     private class MyAdapter extends WearableListView.Adapter {        private final LayoutInflater 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) {            TextView 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 this list to make it more beautiful.


private final class MyItemView extends FrameLayout implements WearableListView.Item {         final CircledImageView imgView;        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 WearableListView demo of this Demo.





For android, I want to implement the function of zooming the listview. The solution is to zoom the listview control. The idea, source code, and demo are as follows:

The landlord solved no ah can send me a demo m it is very grateful to the mailbox 1326644094@qq.com
 
How does android use CheckBox + ListView to obtain the values of multiple controls on the selected items!

The score is too low !!!

Related Article

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.