Simple Converter For Beginners - Android

View: 82    Dowload: 0   Comment: 0   Post by: daii   Category: Mobile applications   Fields: Game - Entertainment

Download  simple-converter-for-beginners.zip (650.60 KB)

You need to Sign In to download the file simple-converter-for-beginners.zip
If you do not have an account then Sign up for free here

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.

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="<a href="http://schemas.android.com/apk/res/android"
  3. " rel="nofollow">http://schemas.android.com/apk/res/android"
  4. </a> xmlns:app="<a href="http://schemas.android.com/apk/res-auto"
  5. " rel="nofollow">http://schemas.android.com/apk/res-auto"
  6. </a> xmlns:tools="<a href="http://schemas.android.com/tools"
  7. " rel="nofollow">http://schemas.android.com/tools"
  8. </a> android:layout_width="match_parent"
  9. android:layout_height="match_parent"
  10. tools:context="com.razormist.simpleconverter.MainActivity">
  11.  
  12. <TextView
  13. android:id="@+id/tv_foot"
  14. android:layout_width="wrap_content"
  15. android:layout_height="wrap_content"
  16. android:text="Foot"
  17. android:textSize="20sp"
  18. android:layout_alignBaseline="@+id/et_foot"
  19. android:layout_toLeftOf="@+id/et_inches"/>
  20.  
  21. <EditText
  22. android:id="@+id/et_foot"
  23. android:layout_height="wrap_content"
  24. android:layout_width="match_parent"
  25. android:layout_centerInParent="true"
  26. android:layout_alignParentTop="true"
  27. android:layout_marginTop="100dp"
  28. android:layout_toRightOf="@+id/tv_foot"
  29. android:inputType="number"/>
  30.  
  31. <TextView
  32. android:id="@+id/tv_inches"
  33. android:layout_height="wrap_content"
  34. android:layout_width="wrap_content"
  35. android:text="Inches"
  36. android:textSize="20sp"
  37. android:layout_alignBaseline="@+id/et_inches"
  38. android:layout_alignBottom="@+id/et_inches"/>
  39.  
  40. <EditText
  41. android:id="@+id/et_inches"
  42. android:layout_height="wrap_content"
  43. android:layout_width="match_parent"
  44. android:layout_centerInParent="true"
  45. android:layout_below="@+id/et_foot"
  46. android:layout_toRightOf="@+id/tv_inches"
  47. android:inputType="number"/>
  48.  
  49. android:id="@+id/btn_convert"
  50. android:layout_height="wrap_content"
  51. android:layout_width="wrap_content"
  52. android:layout_centerInParent="true"
  53. android:layout_below="@id/et_inches"
  54. android:text="Convert"/>
  55.  
  56. android:id="@+id/btn_clear"
  57. android:layout_width="wrap_content"
  58. android:layout_height="wrap_content"
  59. android:layout_centerInParent="true"
  60. android:layout_below="@+id/btn_convert"
  61. android:text="Clear"/>
  62.  
  63. </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.

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="<a href="http://schemas.android.com/apk/res/android"
  3. package="com.razormist.simpleconverter">
  4.  
  5. <application
  6. " rel="nofollow">http://schemas.android.com/apk/res/android"
  7. package="com.razormist.simpl...</a> android:allowBackup="true"
  8. android:icon="@mipmap/ic_launcher"
  9. android:label="@string/app_name"
  10. android:roundIcon="@mipmap/ic_launcher_round"
  11. android:supportsRtl="true"
  12. android:theme="@style/AppTheme">
  13. <activity android:name=".MainActivity"
  14. android:configChanges="orientation"
  15. android:screenOrientation="portrait">
  16. <intent-filter>
  17. <action android:name="android.intent.action.MAIN" />
  18.  
  19. <category android:name="android.intent.category.LAUNCHER" />
  20. </intent-filter>
  21. </activity>
  22. </application>
  23. </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.

  1. package com.razormist.simpleconverter;
  2.  
  3. import android.os.Debug;
  4. import android.provider.Settings;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.util.Log;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.Toast;
  12.  
  13. public class MainActivity extends AppCompatActivity {
  14.  
  15. EditText et_foot, et_inches;
  16. Button btn_convert, btn_clear;
  17.  
  18. @Override
  19. protected void onCreate(Bundle savedInstanceState) {
  20. super.onCreate(savedInstanceState);
  21. setContentView(R.layout.activity_main);
  22.  
  23. et_foot = (EditText)findViewById(R.id.et_foot);
  24. et_inches = (EditText)findViewById(R.id.et_inches);
  25. btn_convert = (Button)findViewById(R.id.btn_convert);
  26. btn_clear = (Button)findViewById(R.id.btn_clear);
  27.  
  28. btn_convert.setOnClickListener(new View.OnClickListener() {
  29. @Override
  30. public void onClick(View v) {
  31. String strCentimeter = et_foot.getText().toString();
  32. String strInches = et_inches.getText().toString();
  33.  
  34. if(!strCentimeter.equals("") && strInches.equals("")) {
  35. double foot = Double.valueOf(et_foot.getText().toString());
  36. double inches = foot * 12;
  37. et_inches.setText(String.valueOf(inches));
  38.  
  39. }else if (!strInches.equals("") && strCentimeter.equals("")){
  40. double inches = Double.valueOf(et_inches.getText().toString());
  41. double foot = inches * 0.0833333;
  42. et_foot.setText(String.valueOf(foot));
  43.  
  44. }else if(!strCentimeter.equals("") && !strInches.equals("")){
  45. Toast.makeText(getApplicationContext(), "Please clear the text field first!", Toast.LENGTH_SHORT).show();
  46. }
  47. }
  48. });
  49.  
  50. btn_clear.setOnClickListener(new View.OnClickListener() {
  51. @Override
  52. public void onClick(View v) {
  53. et_foot.setText("");
  54. et_inches.setText("");
  55. }
  56. });
  57.  
  58. }
  59. }

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!!

Simple Converter For Beginners - 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.....

Posted on 13-03-2018 

Comment:

To comment you must be logged in members.

Files with category

  • 8-bit LED Binary Counter

    8-bit LED Binary Counter

    View: 24    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Other

    This article offers a simple implementation of the binary counter powered by Raspberry PI3 and 8 LEDs. It is very similar to what was done before for Arduino board in the previous article Connecting an Arduino to a Breadboard to Light Up LEDs. In...

  • Chat App

    Chat App

    View: 36    Download: 1   Comment: 0

    Category: Android     Fields: none

    This is a Chat App for Android mobile. You can make separate chat with you partner. I'm using Mysql Database and Php code and All APIs are develop on PHP (REST APIs). My whatsApp:+918285672453: Email ID: nirbhayiise@gmail.com

  • Tower Defense 3D

    Tower Defense 3D

    View: 25    Download: 0   Comment: 0

    Category: Android     Fields: Game - Entertainment

    The goal in this game is to protect your territory against the attacking enemies. Place defensive structures on or along their path of attack to prevent them reaching your base. Strategic choice and positioning of defensive elements is an essential...

  • Flap the Bird

    Flap the Bird

    View: 22    Download: 0   Comment: 0

    Category: Android     Fields: Game - Entertainment

    Tap your screen to make the bird fly. While you are flying there are destruction that will stop you. Avoid hitting the floor and flying to high this will deduct your life. You can collect coins and life along the way. For more mobile games and...

  • Bad Santa

    Bad Santa

    View: 28    Download: 0   Comment: 0

    Category: Android     Fields: Game - Entertainment

    This is a simple shooting game where the Bad Santa is shooting the bad snowman and reindeer. You can collect coins and life along the way. For more mobile games and tutorials you can visit this site.

  • Flappy Halloween Game

    Flappy Halloween Game

    View: 24    Download: 0   Comment: 0

    Category: Android     Fields: Game - Entertainment

    Flappy Halloween is a simple game, tap the screen to move the player. Shoot the pumpkin in the ring to gain score. Avoid hitting the flying destructions and falling from the ground. Since the Halloween is coming this game is really perfect to play...

  • Tilt Ball Game

    Tilt Ball Game

    View: 25    Download: 0   Comment: 0

    Category: Android     Fields: Game - Entertainment

    This game is simple you need to tilt your device to make the ball move in your own desired direction. Reach the finish line before the time ends and move to the next level.

  • Sky Rise 3D Game

    Sky Rise 3D Game

    View: 43    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    Stack up the blocks as high as you can to build a tower. Align the blocks on top of each other. If you manage to place the block exactly on the one before it, it will not lose size. Sloppy placement on the other hand will cut off the blocks and...

 
File suggestion for you
File top downloads
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd