JamesPJ
Gag Creator
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
Operating System
Android
In this tutorial we will try to create a Simple Rating Bar using Android. This simple app can used on some application that needed a review system to their quality. Android is a mobile operating system developed by Google. It used in several gadget like smartphone, tablet, and even television. Android is open source to developers who has an interest in developing mobile apps. It also provide an adaptive framework that allow the developer to develop an apps in a simpler way. So let's now do the coding...
Getting Started:
First you will have to download & install the Android Development IDE (Android Studio or Eclipse). Android Studio is an open source development feel free to develop your things.
Here's the link for the Android Studio https://developer.android.com/studio/index.html.
Layout Design
We will now create the design for the application, first to do is to create a resource that we will be using for the design. To create the resource, go to drawable folder then create a new xml file named button_style. Then write these certain block of codes inside the newly created file.
Now that we're done with the graphic resource we will create then layout of the apps. First locate the layout file called activity_main.xml, this is the default name when create a new activity. Then write these codes inside your layout file.
Android Manifest File
The Android Manifest file provides essential information about your app to the Android system in which the system must required before running the code. It describe the overall information about the application. It contains some libraries that needed to access the several method within the app.
The Main Function
This code contains the main function of the application. This code will allow you to select your desire star and prompt some confirmation when the button is clicked. To start with first locate your MainActivity java file and open it, then write these some important variables inside the MainActivity class.
Then write these several method inside the activity class to make the apps work properly.
Finally, initialize all the methods inside the onCreate method to run the application.
Try to run the app and see if it worked.
There you have it we create a Simple Rating Bar using Android. I hope that this tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!!
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
Android
In this tutorial we will try to create a Simple Rating Bar using Android. This simple app can used on some application that needed a review system to their quality. Android is a mobile operating system developed by Google. It used in several gadget like smartphone, tablet, and even television. Android is open source to developers who has an interest in developing mobile apps. It also provide an adaptive framework that allow the developer to develop an apps in a simpler way. So let's now do the coding...
Getting Started:
First you will have to download & install the Android Development IDE (Android Studio or Eclipse). Android Studio is an open source development feel free to develop your things.
Here's the link for the Android Studio https://developer.android.com/studio/index.html.
Layout Design
We will now create the design for the application, first to do is to create a resource that we will be using for the design. To create the resource, go to drawable folder then create a new xml file named button_style. Then write these certain block of codes inside the newly created file.
- <?
xml version=
"1.0"
encoding=
"utf-8"
?>
- <
selector xmlns:
android=
"http://schemas.android.com/apk/res/android"
>
- <
item>
- <
shape android:
shape=
"rectangle"
>
- <
corners android:
radius=
"15dp"
/>
- <
solid android:
color=
"#337AB7"
/>
- </
shape>
- </
item>
- </
selector>
Now that we're done with the graphic resource we will create then layout of the apps. First locate the layout file called activity_main.xml, this is the default name when create a new activity. Then write these codes inside your layout file.
- <?
xml version=
"1.0"
encoding=
"utf-8"
?>
- <
RelativeLayout xmlns:
android=
"http://schemas.android.com/apk/res/android"
- xmlns:
app=
"http://schemas.android.com/apk/res-auto"
- xmlns:
tools=
"http://schemas.android.com/tools"
- android:
layout_width=
"match_parent"
- android:
layout_height=
"match_parent"
- tools:
context=
"com.razormist.simpleratingbar.MainActivity"
>
- <
RatingBar
- android:
id=
"@+id/rb_rate"
- android:
layout_width=
"wrap_content"
- android:
layout_height=
"wrap_content"
- android:
layout_alignParentTop=
"true"
- android:
layout_centerHorizontal=
"true"
- android:
layout_marginTop=
"192dp"
- android:
isIndicator=
"false"
- android:
numStars=
"5"
- android:
rating=
"0"
- android:
stepSize=
"1"
/>
- <
TextView
- android:
id=
"@+id/tv_result"
- android:
layout_width=
"wrap_content"
- android:
layout_height=
"wrap_content"
- android:
layout_marginTop=
"42dp"
- android:
layout_alignParentTop=
"true"
- android:
textSize=
"40sp"
- android:
layout_centerHorizontal=
"true"
/>
- <
Button
- android:
id=
"@+id/btn_submit"
- android:
layout_height=
"wrap_content"
- android:
layout_width=
"wrap_content"
- android:
layout_below=
"@id/rb_rate"
- android:
layout_centerInParent=
"true"
- android:
layout_marginTop=
"50dp"
- android:
text=
"Submit"
- android:
background=
"@drawable/button_style"
- android:
textColor=
"#fff"
/>
- </
RelativeLayout>
Android Manifest File
The Android Manifest file provides essential information about your app to the Android system in which the system must required before running the code. It describe the overall information about the application. It contains some libraries that needed to access the several method within the app.
- <?
xml version=
"1.0"
encoding=
"utf-8"
?>
- <
manifest xmlns:
android=
"http://schemas.android.com/apk/res/android"
- package
=
"com.razormist.simpleratingbar"
>
- <
application
- android:
allowBackup=
"true"
- android:
icon=
"@mipmap/ic_launcher"
- android:
label=
"@string/app_name"
- android:
roundIcon=
"@mipmap/ic_launcher_round"
- android:
supportsRtl=
"true"
- android:
theme=
"@Style/AppTheme"
>
- <
activity android:
name=
".MainActivity"
- android:
configChanges=
"orientation"
- android:
screenOrientation=
"portrait"
>
- <
intent-
filter>
- <
action android:
name=
"android.intent.action.MAIN"
/>
- <
category android:
name=
"android.intent.category.LAUNCHER"
/>
- </
intent-
filter>
- </
activity>
- </
application>
- </
manifest>
The Main Function
This code contains the main function of the application. This code will allow you to select your desire star and prompt some confirmation when the button is clicked. To start with first locate your MainActivity java file and open it, then write these some important variables inside the MainActivity class.
- private
Button
btn_submit;
- private
TextView tv_result;
- private
RatingBar rb_rate;
Then write these several method inside the activity class to make the apps work properly.
- void
InitializeVariables(
)
{
- rb_rate =
(
RatingBar)
findViewById(
R.id
.rb_rate
)
;
- btn_submit =
(
Button
)
findViewById(
R.id
.btn_submit
)
;
- tv_result =
(
TextView)
findViewById(
R.id
.tv_result
)
;
- }
- void
RatingUpdate(
)
{
- rb_rate.setOnRatingBarChangeListener
(
new
RatingBar.OnRatingBarChangeListener
(
)
{
- @Override
- public
void
onRatingChanged(
RatingBar ratingBar, float
rating, boolean
fromUser)
{
- tv_result.setText
(
"Rating: "
+
String
.valueOf
(
Math
.round
(
rating)
)
)
;
- }
- }
)
;
- }
- void
SubmitRating(
)
{
- btn_submit.setOnClickListener
(
new
View
.OnClickListener
(
)
{
- @Override
- public
void
onClick(
View
v)
{
- Toast.makeText
(
MainActivity.this
, "Thanks for the rate"
, Toast.LENGTH_SHORT
)
.show
(
)
;
- }
- }
)
;
- }
Finally, initialize all the methods inside the onCreate method to run the application.
- InitializeVariables(
)
;
- RatingUpdate(
)
;
- SubmitRating(
)
;
Try to run the app and see if it worked.
There you have it we create a Simple Rating Bar using Android. I hope that this tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!!
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
You must upgrade your account or reply in the thread to view hidden text.