GithubHelp home page GithubHelp logo

Comments (8)

AigeStudio avatar AigeStudio commented on September 25, 2024

你怎么设置的?我通过线程或回调事件设置都可以被刷新:

        new Thread(new Runnable() {
            @Override
            public void run() {
                SystemClock.sleep(3000);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        final List<String> newData = new ArrayList<>();
                        newData.add("AigeStudio");
                        newData.add("Fuck");
                        newData.add("Bull shit");
                        straightPicker.setData(newData);
                        straightPicker.setItemIndex(0);
                    }
                });
            }
        }).start();

点击事件:

            case R.id.main_obtain_straight_btn:
                final List<String> newData = new ArrayList<>();
                newData.add("AigeStudio");
                newData.add("Fuck");
                newData.add("Bull shit");
                straightPicker.setData(newData);
                straightPicker.setItemIndex(0);
                break;

from wheelpicker.

xushaun avatar xushaun commented on September 25, 2024

很感谢您的答复,其实我是要做省市2级滚动,当省变化时我需要更改city的data
但是代码如下实现确实如我所说,不能正确显示

cityList是个2维列表
province.setOnWheelChangeListener(new OnWheelChangeListener() {

        @Override
        public void onWheelSelected(int index, String data) {
            // TODO Auto-generated method stub
            city.setData(cityList.get(index));
            city.setItemIndex(0);


        }
                 ....

}

from wheelpicker.

AigeStudio avatar AigeStudio commented on September 25, 2024

= = 不会吧,数据没问题么,你可以参考WheelDatePicker日期选择这个控件,跟省市区联动逻辑是一致的,只是数据不同而已,WheelDatePicker在滑动后会根据不同的月份显示不同的天数,因为每个月天数不是相同的

from wheelpicker.

xushaun avatar xushaun commented on September 25, 2024

WheelDatePicker在滑动后会根据不同的月份显示不同的天数,能麻烦你帮我找找关键代码吗,我也一直在找从31天切换到30天的月份后picker会自动切换回去,我代码大概看了下,原以为是因为DayPicker调用了init方法,但是试了下Init打方法还是没有效果

from wheelpicker.

AigeStudio avatar AigeStudio commented on September 25, 2024

WheelDayPicker里面setCurrentYearAndMonth方法:

    public void setCurrentYearAndMonth(int year, int month) {
        setYear(year);
        setMonth(month);
        initData();
        checkScrollState();
    }

checkScrollState

from wheelpicker.

xushaun avatar xushaun commented on September 25, 2024

这个方法我试过了
@OverRide
public void onWheelSelected(int index, String data) {
// TODO Auto-generated method stub
city.clearCache();

            city.setData(cityList.get(index));
            city.setItemIndex(0);
            //city.checkScrollState();
            //city.requestLayout();
            Log.i("test", "province index is " + index);
            Log.i("test", "province data is " + data);

        }

这些我全试了,还是不行,可以的话,我想把源代码Demo给你,你帮我看看,如果你有空的话,留个邮箱给我,我发demo给你

from wheelpicker.

AigeStudio avatar AigeStudio commented on September 25, 2024

[email protected]

from wheelpicker.

xushaun avatar xushaun commented on September 25, 2024

感谢您的帮助,当我在准备Demo的时候,我又尝试了下,发现的2个问题解决了
1:当第一次的的数据源size大于第二次的数据源size时,可能会出现数据显示不出来,checkScrollState可以解决这个问题
2:有时候数据源切换的时候,pick不会自动刷新,显示的还是原来的数据,需要点击picker才会显示最新的数据,手动调用invalidate可以解决

以下代码尝试过,没有问题,再次感谢您的帮助

province.setOnWheelChangeListener(new OnWheelChangeListener() {

        @Override
        public void onWheelSelected(int index, String data) {
            // TODO Auto-generated method stub
            city.setData(cityList.get(index));
            city.setItemIndex(0);
            city.checkScrollState();
            city.invalidate();
        }

from wheelpicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.