android RatingBar 自定义

<pre name="code" class="html">


如图:红框所示效果: 小人开了个淘宝店欢迎大婶们来往关注:左手阡陌

package com.qiao.ratingbartest;


import android.app.Activity;
import android.os.Bundle;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.Toast;


public class MainActivity extends Activity {
	
	private RatingBar ratingBar_android;
	private RatingBar ratingBar_self;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initListener();
        
    }
	private void initListener() {
		ratingBar_android.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
			
			@Override
			public void onRatingChanged(RatingBar arg0, float arg1, boolean arg2) {
				Toast.makeText(MainActivity.this, "评分:= "+arg1, Toast.LENGTH_SHORT).show();
			}
		});
        ratingBar_self.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
        	
        	@Override
        	public void onRatingChanged(RatingBar arg0, float arg1, boolean arg2) {
        		Toast.makeText(MainActivity.this, "评分:= "+arg1, Toast.LENGTH_SHORT).show();
        	}
        });
	}
	private void initView() {
		ratingBar_android = (RatingBar) findViewById(R.id.ratingBar_android);
        ratingBar_self = (RatingBar) findViewById(R.id.ratingBar_self);
	}


}


<style name="myCustomizeRatingBar" parent="@android:style/Widget.RatingBar">
    	    <item name="android:progressDrawable">@drawable/star_conf_file</item>
    	    <item name="android:minHeight">16dip</item>
    	    <item name="android:maxHeight">16dip</item>
    	</style>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <RatingBar
        android:id="@+id/ratingBar_android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <RatingBar
        android:id="@+id/ratingBar_self"
        style="@style/myCustomizeRatingBar"
        android:layout_width="wrap_content"
        android:layout_height="18.5dp"
        android:layout_marginLeft="20dp"
        android:isIndicator="false"
        android:numStars="5"
        android:stepSize="1" />

</LinearLayout>






阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载,如需强制转载,请注明出处且需对文章进行评论声明转载。 https://blog.csdn.net/u014449096/article/details/46828679
个人分类: Android
上一篇关于百度地图poi检索不出数据,onGetPoiResult不执行(其他功能类似)
下一篇帧动画模仿wifi链接信号
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭