gabykh
De-Anonymization Specialist
LEVEL 1
500 XP
Operating System
Android
In this tutorial we will try to create a Simple Converter Using Android. Android is a widely-adopted open-source project. Android is an open source so that developer find it easy to develop and expand new features. Android is available to any devices such as TV, phones, watches etc. So now let's 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 locate the activity_main.xml and click text to view the script. Then copy and paste the code below.
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.
The Main Function
This code contains the main function of the application.This code will automatically calculate the values of each Edit Text when Convert button is click.
There you have it we successfully created a Simple Convert using Android. I hope that this simple tutorial help you to learn android in a basic way. 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 Converter Using Android. Android is a widely-adopted open-source project. Android is an open source so that developer find it easy to develop and expand new features. Android is available to any devices such as TV, phones, watches etc. So now let's 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 locate the activity_main.xml and click text to view the script. Then copy and paste the code below.
- <?
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.simpleconverter.MainActivity"
>
- <
TextView
- android:
id=
"@+id/tv_foot"
- android:
layout_width=
"wrap_content"
- android:
layout_height=
"wrap_content"
- android:
text=
"Foot"
- android:
textSize=
"20sp"
- android:
layout_alignBaseline=
"@+id/et_foot"
- android:
layout_toLeftOf=
"@+id/et_inches"
/>
- <
EditText
- android:
id=
"@+id/et_foot"
- android:
layout_height=
"wrap_content"
- android:
layout_width=
"match_parent"
- android:
layout_centerInParent=
"true"
- android:
layout_alignParentTop=
"true"
- android:
layout_marginTop=
"100dp"
- android:
layout_toRightOf=
"@+id/tv_foot"
- android:
inputType=
"number"
/>
- <
TextView
- android:
id=
"@+id/tv_inches"
- android:
layout_height=
"wrap_content"
- android:
layout_width=
"wrap_content"
- android:
text=
"Inches"
- android:
textSize=
"20sp"
- android:
layout_alignBaseline=
"@+id/et_inches"
- android:
layout_alignBottom=
"@+id/et_inches"
/>
- <
EditText
- android:
id=
"@+id/et_inches"
- android:
layout_height=
"wrap_content"
- android:
layout_width=
"match_parent"
- android:
layout_centerInParent=
"true"
- android:
layout_below=
"@+id/et_foot"
- android:
layout_toRightOf=
"@+id/tv_inches"
- android:
inputType=
"number"
/>
- <
Button
- android:
id=
"@+id/btn_convert"
- android:
layout_height=
"wrap_content"
- android:
layout_width=
"wrap_content"
- android:
layout_centerInParent=
"true"
- android:
layout_below=
"@id/et_inches"
- android:
text=
"Convert"
/>
- <
Button
- android:
id=
"@+id/btn_clear"
- android:
layout_width=
"wrap_content"
- android:
layout_height=
"wrap_content"
- android:
layout_centerInParent=
"true"
- android:
layout_below=
"@+id/btn_convert"
- android:
text=
"Clear"
/>
- </
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.
- <?
xml version=
"1.0"
encoding=
"utf-8"
?>
- <
manifest xmlns:
android=
"http://schemas.android.com/apk/res/android"
- package
=
"com.razormist.simpleconverter"
>
- <
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 automatically calculate the values of each Edit Text when Convert button is click.
- package
com.razormist.simpleconverter
;
- import
android.os.Debug
;
- import
android.provider.Settings
;
- import
android.support.v7.app.AppCompatActivity
;
- import
android.os.Bundle
;
- import
android.util.Log
;
- import
android.view.View
;
- import
android.widget.Button
;
- import
android.widget.EditText
;
- import
android.widget.Toast
;
- public
class
MainActivity extends
AppCompatActivity {
- EditText et_foot, et_inches;
- Button
btn_convert, btn_clear;
- @Override
- protected
void
onCreate(
Bundle savedInstanceState)
{
- super
.onCreate
(
savedInstanceState)
;
- setContentView(
R.layout
.activity_main
)
;
- et_foot =
(
EditText)
findViewById(
R.id
.et_foot
)
;
- et_inches =
(
EditText)
findViewById(
R.id
.et_inches
)
;
- btn_convert =
(
Button
)
findViewById(
R.id
.btn_convert
)
;
- btn_clear =
(
Button
)
findViewById(
R.id
.btn_clear
)
;
- btn_convert.setOnClickListener
(
new
View
.OnClickListener
(
)
{
- @Override
- public
void
onClick(
View
v)
{
- String
strCentimeter =
et_foot.getText
(
)
.toString
(
)
;
- String
strInches =
et_inches.getText
(
)
.toString
(
)
;
- if
(
!
strCentimeter.equals
(
""
)
&&
strInches.equals
(
""
)
)
{
- double
foot =
Double
.valueOf
(
et_foot.getText
(
)
.toString
(
)
)
;
- double
inches =
foot *
12
;
- et_inches.setText
(
String
.valueOf
(
inches)
)
;
- }
else
if
(
!
strInches.equals
(
""
)
&&
strCentimeter.equals
(
""
)
)
{
- double
inches =
Double
.valueOf
(
et_inches.getText
(
)
.toString
(
)
)
;
- double
foot =
inches *
0.0833333
;
- et_foot.setText
(
String
.valueOf
(
foot)
)
;
- }
else
if
(
!
strCentimeter.equals
(
""
)
&&
!
strInches.equals
(
""
)
)
{
- Toast.makeText
(
getApplicationContext(
)
, "Please clear the text field first!"
, Toast.LENGTH_SHORT
)
.show
(
)
;
- }
- }
- }
)
;
- btn_clear.setOnClickListener
(
new
View
.OnClickListener
(
)
{
- @Override
- public
void
onClick(
View
v)
{
- et_foot.setText
(
""
)
;
- et_inches.setText
(
""
)
;
- }
- }
)
;
- }
- }
There you have it we successfully created a Simple Convert using Android. I hope that this simple tutorial help you to learn android in a basic way. 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.