为WheelView添加标题

时间:2012-02-16 17:00:05

标签: android android-widget android-view android-custom-view android-gui

我正在使用WheelView(http://code.google.com/p/android-wheel/)让用户输入一定数量的单位(例如kg)。我想在它旁边显示当前值的单位,如图所示。

WheelView with caption "hour"

可悲的是,WheelView不支持标签(不再)。知道如何实现这个吗?

2 个答案:

答案 0 :(得分:2)

我知道这是不完全你想要什么,但最接近它,它可以轻松完成。您可以在格式字符串中包含您的标记,如下所示:

wheelView.setViewAdapter(new NumericWheelAdapter(getActivity(), 0, 23, "%02d hour"))

答案 1 :(得分:0)

你可以尝试一下:

String [] dayArray = {“2 JAN”,“3 jan”,“4 jan”,“5 jan”,“6 jan”,“7 jan”,“8 jan”};     WheelView日;

day = (WheelView) findViewById(R.id.day);
        day.setViewAdapter(new DayArrayAdapter(MainActivity.this, dayArray, weekDay));


        day.addChangingListener(new OnWheelChangedListener() {

            @Override
            public void onChanged(WheelView wheel, int oldValue, int newValue) {

                Log.e("onChanged hours", dayArray[newValue]);

                mCustomDate = dayArray[newValue];
                mFinalTime = mCustomDate+" "+mCustomHour+mCustomMinute+" "+mAMORPM;
                mSeletedDateTextView.setText(mFinalTime);
            }
        });