向 WheelView 添加标题

发布于 2025-01-06 06:37:33 字数 308 浏览 1 评论 0原文

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

带有标题“hour”的WheelView

遗憾的是,WheelView 不再支持标签。知道我如何实现这个吗?

I'm using the WheelView( http://code.google.com/p/android-wheel/ ) to let users input a number of a certain unit (e.g. kg). I'd like to display the unit of the current value next to it like it is shown in this picture.

WheelView with caption "hour"

Sadly, the WheelView doesn't support labelling (anymore). Any idea how I can implement this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放血 2025-01-13 06:37:33

我知道这不完全是你想要的,但是最接近它的东西,而且可以很容易地完成。您可以将标记包含在格式字符串中,如下所示:

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

i know this is not exactly what you want, but the closest thing to it, and it can be done easily. you could include your tag in the format string, like this:

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

高跟鞋的旋律 2025-01-13 06:37:33

你可以尝试一下:

String[] dayArray = {"2 JAN", "3 jan", "4 jan", "5 jan", "6 jan", "7 jan", "8 jan"};
轮景日;

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);
            }
        });

You can try it:

String[] dayArray = {"2 JAN", "3 jan", "4 jan", "5 jan", "6 jan", "7 jan", "8 jan"};
WheelView day;

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);
            }
        });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文