Addition of Two value - Android Development

Posted by menotor Sabtu, 11 Mei 2013 0 komentar
M
ost of the tutorials starts with "Hello World" applications for beginners to start with. In this article, I have jumped a step forward to come up with a bundle of tutorials which I hope will be useful for Android developers (beginners) to start with addition of two values.

Android has a such a great GUI beginners also can understand easily like me. If you are developing advance app for android its better to code in XML directly. Now let's move on a first step forward tutorial. I share source code of app below and i also shared .APK file of it which you can download from mediafire.

The Android Mania The Android Mania
A World Of Possiblities
Gratis   star on dark img The Android Maniastar on dark img The Android Maniastar on dark img The Android Maniastar on dark img The Android Maniastar on dark img The Android Mania
Application Requirement:
  • Android 2.3.3 up
Description:
  • It's just addition application.
Source Code Of My First Application
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Addition</string>
    <string name="hello_world">Hello world!</string>
    <string name="menu_settings">Settings</string>
    <string name="type_text">Type Text</string>
    <string name="sum">Sum</string>
    <string name="Null"></string>
</resources>
MainActivity.java
package com.android.addition;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
int num1,num2,temp=0;
Button sum;
EditText text1,text2;
TextView ans;
String myAns;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text1 = (EditText) findViewById(R.id.editText1);
text2 = (EditText) findViewById(R.id.editText2);
ans = (TextView) findViewById(R.id.textView1);
sum = (Button)findViewById(R.id.button1);
sum.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
num1 = Integer.parseInt(text1.getText().toString());
num2 = Integer.parseInt(text2.getText().toString());
temp = num1+num2;
myAns = Integer.toString(temp);
ans.setText("Your Total Is " + myAns);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}


TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: Addition of Two value - Android Development
Ditulis oleh menotor
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://androidbox2014.blogspot.com/2013/05/addition-of-two-value-android.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android box.