【问题标题】:How can add Caption in wheel picker?如何在车轮选择器中添加 Caption?
【发布时间】:2023-03-20 04:23:01
【问题描述】:

我想在轮子选择器中添加标题。像这样:

但在我的代码中,它显示在轮子中的所有项目中。这是我的代码:

 final WheelView minute = new WheelView(Mcontex);
 minute.setMinimumHeight(300);
 layoutHome.addView(minute, new LayoutParams(
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1.2f));
 minute.setViewAdapter(new NumericWheelAdapter(context, 1, 23,"%02d hour"));        
 minute.setCurrentItem(0);
 minute.addChangingListener(listener);

我只想在当前行显示标题。

【问题讨论】:

    标签: android caption android-wheel


    【解决方案1】:

    你可以试试:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-08
      • 2018-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多