Android的使用setNumStars变更执行期间星星让收视率的行为怪异 [英] Android using setNumStars to change stars during execution make the ratings act strange

查看:492
本文介绍了Android的使用setNumStars变更执行期间星星让收视率的行为怪异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用rb.setNumStars(INT)改变恒星形成一个给定的默认值(比如5)到一个新的与App preferences(比如4)。在code进行确定,并刷新该片段后,我能看到的星星数目我设置任何整数的变化(条具有1的步长)。

I'm using rb.setNumStars(int) to change the stars form a given default value (say 5) to a new one with app preferences (say 4). The code performs Ok and after refresh the fragment, I can see the change in the stars number to any integer I set (the bar has a StepSize of 1).

问题是,当我尝试设置分级栏上,填充星不与评价值一致,我在陌生的地方取得联系,如果我碰拳头明星来了值,也就是说,我得到一个等级= 1,如果我摸到第二个,我还是有等级= 1和充满恒星是一个和第二个片段。如果我第二和第三颗星之间的联系,我得到等级= 2,我得到两个片段充满恒星。

The problem is that when I try to set the rating on that bar, the filled stars does not coincide with the rating value, and I have to touch in strange places to get come values, i.e. if I touch the fist star, I get a rating = 1, If I touch the second, I still have a rating = 1 and the filled stars are one and a fragment of the second. If I touch between the second and the third star, I get rating = 2 and I get two and a fragment filled stars.

想象一下:如果F是一个全明星,P是部分(但不是作为一个半星)和E是一个空的明星,如果我触碰第二个明星,而第二和第三,我得到的:

Imagine this: if F is a full star, P is a partial (but not as in a half star) and E is an empty star, if I touch the second star, and between the 2nd and the 3rd I get:

在fp E E等级= 1μF在fpë等级= 2

F P E E Rating = 1 F F P E rating = 2

编辑:图像可以在这里找到: http://1drv.ms/1pyq3gS

The images can be found here: http://1drv.ms/1pyq3gS

如果我的价值回归5,酒吧的行为与预期,与充满恒星的评级相符。

If I return the value to 5, the bar behaves as expected, with the filled stars coinciding with the rating.

我不能插入图像,来解释这种行为,但我希望这是很清楚。

I can not insert images, to explain this behavior, but I hope it's clear enough.

有谁知道为什么会出现这种情况,如何纠正呢?

Does anybody knows why is this happening and how to correct it?

推荐答案

看来,我能回答我的问题。

It seems that I was able to answer my own question.

由于这是进度条的延伸,I'm猜测,当我改变数星星,一个进度条一直延伸到新的宽度,但保持其原始值,而不是反映了必须填写的部分。通过使用SETMAX差饷吧,我觉得I'm设置这一栏的新限制,所以,我改变数星星和最大值设置为数字,像这样的:

As this is an extension of the progress bar, I´m guessing that when I change the number of stars, a progress bar is stretching to the new width, but keeping it's original values, not reflecting the portion that must fill. By using setMax for the Rating Bar, I think I´m setting the new limits for this bar, so, I changed the number of stars and set the max value to that number, like this:

RatingBar rb = (RatingBar) view.findViewById(rbars[r]);
rb.setNumStars(Integer.valueOf(SP.getString(rchars[r], "3")));
rb.setMax(Integer.valueOf(SP.getString(rchars[r],"3")));
rb.setRating(2);

在这种方式的等级与填充分重合。

In this way the rating coincide with the filled stars.

这篇关于Android的使用setNumStars变更执行期间星星让收视率的行为怪异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆