Search in sources :

Example 1 with CarNumberPicker

use of cn.qqtheme.framework.picker.CarNumberPicker in project AndroidPicker by gzu-liyujiang.

the class NestActivity method setContentViewAfter.

@Override
protected void setContentViewAfter(View contentView) {
    final TextView textView = findView(R.id.wheelview_tips);
    WheelView wheelView = findView(R.id.wheelview_single);
    wheelView.setItems(new String[] { "少数民族", "贵州穿青人", "不在56个少数民族之列", "第57个民族" }, 1);
    wheelView.setTextColor(0xFFFF00FF);
    WheelView.LineConfig config = new WheelView.LineConfig();
    //线颜色
    config.setColor(0xFFFF00FF);
    //线透明度
    config.setAlpha(100);
    //线比率
    config.setRatio((float) (1.0 / 10.0));
    //线粗
    config.setThick(ConvertUtils.toPx(this, 10));
    wheelView.setLineConfig(config);
    wheelView.setOnWheelListener(new WheelView.OnWheelListener() {

        @Override
        public void onSelected(boolean isUserScroll, int index, String item) {
            textView.setText("index=" + index + ",item=" + item);
        }
    });
    picker = new CarNumberPicker(this);
    picker.setOffset(3);
    picker.setOnWheelListener(new CarNumberPicker.OnWheelListener() {

        @Override
        public void onFirstWheeled(int index, String item) {
            textView.setText(item + ":" + picker.getSelectedSecondItem());
        }

        @Override
        public void onSecondWheeled(int index, String item) {
            textView.setText(picker.getSelectedFirstItem() + ":" + item);
        }
    });
    ViewGroup viewGroup = findView(R.id.wheelview_container);
    viewGroup.addView(picker.getContentView());
    findViewById(R.id.nest_back).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    findViewById(R.id.nest_carnumber).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            picker.show();
        }
    });
}
Also used : WheelView(cn.qqtheme.framework.widget.WheelView) ViewGroup(android.view.ViewGroup) CarNumberPicker(cn.qqtheme.framework.picker.CarNumberPicker) TextView(android.widget.TextView) WheelView(cn.qqtheme.framework.widget.WheelView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 CarNumberPicker (cn.qqtheme.framework.picker.CarNumberPicker)1 WheelView (cn.qqtheme.framework.widget.WheelView)1