Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在从包含许多条目的 MySQL 表中汇总数字评级(1-5 星)。它将取列中评分的平均值并将其作为变量返回到 Android。
让我们称变量为 $foo。
如何使用 $foo 预设 Android RatingBar,以便它以编程方式根据数据库值更改星数?
使用RatingBar.setRating.
RatingBar.setRating
float foo = 3.5; RatingBar bar = (RatingBar) findViewById(R.id.rating_bar); bar.setRating(foo);