如何做到以下几点?
如果RatingBar有1-3颗星 - 红星.如果RatingBar有4颗星 - 黄星.如果RatingBar有5颗星 - 绿色星星.
((RatingBar) layout.findViewById(R.id.ratingBar)).setProgress(Integer.parseInt(surveyBeans.get(section).get(position).getRate()));
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ratingBar" android:stepSize="1" android:clickable="false"
style="?android:attr/ratingBarStyleSmall" android:layout_gravity="right"
android:layout_marginRight="15dp" />
Run Code Online (Sandbox Code Playgroud)
编辑:
@Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
LinearLayout layout;
if (convertView == null) {
LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = (LinearLayout) inflator.inflate(R.layout.item_survey, null);
} else {
layout = (LinearLayout) convertView;
}
((TextView) layout.findViewById(R.id.questionSurvey)).setText(surveyBeans.get(section).get(position).getQuestion());
RatingBar ratingBar = ((RatingBar) layout.findViewById(R.id.ratingBar));
ratingBar.setProgress(Integer.parseInt(surveyBeans.get(section).get(position).getRate()));
LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);
stars.getDrawable(1).setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
((TextView) layout.findViewById(R.id.commentSurvey)).setText(surveyBeans.get(section).get(position).getComment());
return layout;
} …Run Code Online (Sandbox Code Playgroud) 我用SwipeRefreshLayout谷歌.我有几个问题.
onRefresh()?更新期间如何在屏幕旋转中心而不是顶部进行?
swipeLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_status_info);
swipeLayout.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE, Color.CYAN);
swipeLayout.setOnRefreshListener(this);
@Override
public void onRefresh() {
clearTable(holidayTable);
clearTable(cityayTable);
setData();
}
Run Code Online (Sandbox Code Playgroud)我需要创建一个带背景的按钮并将其放在图片上.我试图LinearLayout Horizontal在它上面下注,然后放上背景图片和按钮.但它看起来不太好.告诉我怎么做?
