Step by Step _android Development Course [27]_ user interface Ratingbar (rating bar)

Source: Internet
Author: User

Focus on technology, enjoy life! --qq:804212028
Browse Links: http://blog.csdn.net/y18334702058/article/details/44624305

    • Topic: User interface Ratingbar (scoring bar)
      -This is very simple, usually use is not much, the general use is to film or book scoring;

Ratingbar Rating Bar (instance)
Activity_main.xml:

<?xml version= "1.0" encoding= "Utf-8"?><linearlayout  xmlns: Android  = "http://schemas.android.com/apk/res/android"  android:layout_width  =" fill_parent " android:layout_height  =" fill_parent " android:orientation  =" vertical " android:id  = "@+id/mainlayout" ;      <ratingbarandroid:id="@+id/ratingbar1"style="android:attr/ Ratingbarstyle "android:layout_width="wrap_content "android:layout_height=" Wrap_content " />                                 </linearlayout>

Mainactivity.java:

Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.widget.RatingBar;ImportAndroid.widget.RatingBar.OnRatingBarChangeListener;ImportAndroid.widget.Toast; Public  class mainactivity extends Activity {Ratingbar ratingbar1;@Override    protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate);        Setcontentview (R.layout.activity_main);        Ratingbar1 = (Ratingbar) Findviewbyid (R.ID.RATINGBAR1); Ratingbar1.setonratingbarchangelistener (NewListener ()); } Class Listener implements onratingbarchangelistener{@Override         Public void onratingchanged(Ratingbar Ratingbar,floatRatingBooleanFromuser) {//TODO auto-generated method stub            Switch(Ratingbar.getid ()) { CaseR.id.ratingbar1:ratingbar1.setrating (rating); Toast.maketext (mainactivity. This,"Rating:"+ string.valueof (rating), Toast.length_long). Show (); Break; }        }    }}

Operation Result:

Focus on technology, enjoy life! --qq:804212028
Browse Links: http://blog.csdn.net/y18334702058/article/details/44624305

Step by Step _android Development Course [27]_ user interface Ratingbar (rating bar)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.