Android查看页面指示符不会在页面滑动时更改颜色

时间:2014-07-23 11:45:04

标签: android viewpagerindicator

我正在实现以下监听器来更改pageindicator

mPager.setOnPageChangeListener(new OnPageChangeListener() {
    @Override
    public void onPageSelected(int arg0) {
        switch (arg0) {
            case 0:
                try {
                    splash_text.setText(sliderText.get(arg0));
                    mIndicator.setFillColor(getResources().getColor(R.color.listyou));
                } catch (Exception e) {}
                break;
            case 1:
                try {
                    splash_text.setText(sliderText.get(arg0));
                    mIndicator.setFillColor(getResources().getColor(R.color.listyou));
                } catch (Exception e) {}
                break;
            case 2:
                try {
                    splash_text.setText(sliderText.get(arg0));
                    mIndicator.setFillColor(getResources().getColor(R.color.listyou));
                } catch (Exception e) {}
                break;
            case 3:
                try {
                    splash_text.setText(sliderText.get(arg0));
                    mIndicator.setFillColor(getResources().getColor(R.color.listyou));
                } catch (Exception e) {}
                break;
            case 4:
                try {
                    splash_text.setText(sliderText.get(arg0));
                    mIndicator.setFillColor(getResources().getColor(R.color.listyou));
                } catch (Exception e) {}
                break;
            default:
                break;
        }
    }
});

如何在页面滑动时更改页面indiactor颜色。当我在做什么     mIndicator.setFillColor(getResources()。getColor(R.color.listyou))它无效。

1 个答案:

答案 0 :(得分:1)

尝试设置颜色。

mIndicator.setFillColor(Color.parseColor(getString(R.color.listyou)));