i would like to save the state of rating bar rating stars? How would i go about doing this?
and also how would i go about getting the number of stars the user has selected? To display in a textView?
Thanks
From developer.android.com :
http://developer.android.com/resources/tutorials/views/hello-formstuff.html#RatingBar
Other Example Here..
http://android-er.blogspot.com/2010/02/ratingbar.html
If you want to customize RatingBar eg. Displaying other image than default Star
refer How to create Custom Ratings bar in Android
This example shows Toast message when user selects Ratings.
& Obviously you will have to customize it according to your needs (as you told you want to display it in TextView).
You can define a TextView in xml file & set its text property when Rating has changed.
Related
I am playing with rating bar. I follow One good tutorial for customizing rating bar.
I am Facing some problem:
This tutorial use one image for rating bar but i don't want to use
any image for rating bar. i need to use android Rating bar widget.
When i use Android Rating widget it show too large or too small(when i use style="?android:attr/ratingBarStyleSmall">) with
having more than 10 star whether we set android:numStars="5" or not.
Ok. Suppose i use any image for that but when i set rating = 2.5 then
image still not change i use this method ratingBar.setRating(Float.parseFloat("2.0"));.
Here i use image for this rating bar
my code is same as which given above link.
Can you give me some reference by using i can use Rating bar widget in small shape with only 5 star?
I don't want to use any image i want to use only android rating widget.
I stuck here from last 5 hours.
Any help appreciated.
I would like to use the Spinner as view-switching controller at Action Bar in my Android app, just like the native mail app (see part #2 at Android Common App UI).
So far I have managed putting the Spinner in the action bar and populating it with array of strings (see screen shot here) by looking at the example code at Android Developers.
My questions are:
How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app.
Why is the item text in the Spinner black and not white as the rest of the text in action bar?
I'm developing for Android version 4.0 and later.
How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
Call setDisplayShowTitleEnabled(false) on the ActionBar for this activity.
How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app.
Create layouts that have more than one line in them that you use with your SpinnerAdapter.
Why is the item text in the Spinner black and not white as the rest of the text in action bar?
Probably you need to use getThemedContext() on ActionBar to get the Context to use with your SpinnerAdapter constructor.
1.How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
in order to remove this title you should edit the activity tag in manifast to android:label=" "
do this in every activity you wish for
3.Why is the item text in the Spinner black and not white as the rest of the text in action bar?
you can create style for the text color like theme.holo.light and apply this theme to your activity
1) How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
If you are using a standard theme, you can just look for the "noTitleBar" version and add it
android:theme="#android:style/Theme.Light.NoTitleBar"
FYI: check this link, it contains more detailed info
2) How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app
I really dont get what you wanna do. If u need a text above and one below a spinning icon, you can just create a linear layout (a vertical one) adding inside of it the 3 elements
3) Why is the item text in the Spinner black and not white as the rest of the text in action bar?
You can modify every element in your layout by editing the style you are using.
FYI: basic theme in android
I'm working on an app that needs to create a non editable small style rating bar with 4 stars dynamically.
When I call setRating(4) it shows 4 stars without any problem.
But when I call setRating(3) it shows 3 and half stars.
setRating(2) shows 2 stars correctly,
but setrating(1) shows 1 and half stars.
When I use a normal rating bar in another activity it works fine, but when I use the small style non editable rating bar it doesn't work properly.
Does this have anything to do with the api level or small style non editable rating bar?
Initialization is done like this:
RatingBar ioRatingBar = new RatingBar(this,null,android.R.attr.ratingBarStyleSmall);
ioRatingBar.setNumStars(4);
ioRatingBar.setRating(3);
You need to set the step size of the RatingBar like this
ratingBar.setStepSize(1.0);
and also try to define the max rating as:
ratingBar.setMax(4);
If exist padding, remove. I suggest replace with margin.
I have a custom style for my rating bar. I want to change the star image from the code (deending on some user operation).
Is there anyway to change the style? the image?
I may try to re-inflate the ratingbar but I am not sure it will be OK, or if it is the correct way.
I would like to modify the background of the title bar of the dropdown dialog associated to a spinner.
If this is not possible I would like to know what resource is used to draw this background android.R.drawable.* ?
This is an effort of uniformity for my various pop ups in my application.
You can change everything using styles and themes.
Take a look at this example for buttons:
http://blog.androgames.net/40/custom-button-style-and-theme/