Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Android Sample Project Part -1

Android Sample Project Part -1 


to create new sample android project and run it should have eclipse , genymotion for run and test it at local. And this is sample project demo.
Demo tax on Salary (android sample project)
1) step 1




2) step 2 - input currency (riels) to text box ,then show result pay tax.


Next tutorial we will create project step by step.

Android Sample Project Part -2

In this section we will create sample project step by step.

1) Create your project name in eclipse.
2)  In activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/lbltitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginTop="32dp"
   
        android:gravity="center_horizontal"
        android:text="@string/SalaryTax"
        android:textColor="#0101DF"
        android:textSize="35sp" />

    <TextView
        android:id="@+id/lblsalary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/lbltitle"
        android:layout_marginTop="37dp"
        android:text="@string/Salary"
        android:textColor="#0101DF"
        android:textSize="25sp" />

    <EditText
        android:id="@+id/txtsalary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/lblsalary"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/lblsalary"
        android:ems="10"
        android:textSize="15sp"
        android:inputType="number"
       android:width="200dp" >
        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/btncal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/CalculateTax"
        android:textColor="#0101DF"
        android:width="110dp" />

    <TextView
        android:id="@+id/lblnet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignLeft="@+id/lblsalary"
        android:layout_below="@+id/btncal"
        android:layout_marginTop="37dp"
        android:text="@string/NetSalary"
       android:textSize="20sp" />

    <TextView
        android:id="@+id/lbltax"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/lblnet"
        android:layout_below="@+id/lblnet"
        android:layout_marginTop="48dp"
        android:text="@string/Tax"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/txtsalary"
        android:layout_alignLeft="@+id/txtsalary"
        android:text="@string/introductionTaz" />

</RelativeLayout>







Android Sample Project Part - 3

Android Sample Project Part - 3


In  this section you will know more android sample project , and this part we will learn more about xml file.
In this part we will store variable name and values in String.xml file in android sample project .
To store variable and values in string.xml to ,go to android project 



<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">salary</string>
    <string name="action_settings">Settings</string>
     <string name="SalaryTax">Tax payment</string>
      <string name="Salary">Salary</string>
      <string name="CalculateTax">Calcualte</string>
     <string name="NetSalary">balance</string>
      <string name="Tax">Tax</string>
      <string name="introductionTaz">1$ = 4000 Riels</string>
    

</resources>

You saw some variable and values stores in string.xml file and ti was used activity_main.xml 
Example:1
android:text="@string/SalaryTax" ,also you can call to use it in MainActivity.java like this 
Example:2
Toast.makeText(MainActivity.this, getString(R.string.SalaryTax, comp, guesses), 
            Toast.LENGTH_LONG).show();

Android Sample Project Part - 4

Android Sample Project Part - 4

In this section you will know more about MainActivity.java and Concept in android sample project 
In this app you will know how to declare variable and some conditions in Salary Tax.

There are  some conditions that we will to do it in MainActivity.java


Monthly salary (Riels)Rate
0 - 800,0000%
800,001 - 1,250,0005%
1,250,001 - 8,500,00010%
8,500,001 - 12,500,00015%
12,500,001 - upwards20%
public class MainActivity extends Activity {
public Button CalculateTax;
public EditText Salary;
public TextView NetSalary;
public TextView Tax;

public double salarys, netsalary,tax = 0;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
                //call method 
addOnclickListener();
}
private void addOnclickListener() {
// TODO Auto-generated method stub
CalculateTax = (Button)findViewById(R.id.btncal);
Salary = (EditText)findViewById(R.id.txtsalary);
NetSalary = (TextView)findViewById(R.id.lblnet);
Tax = (TextView)findViewById(R.id.lbltax);

CalculateTax.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if(Salary.getText().toString().equals("")){
Toast.makeText(getApplicationContext(), "Please Fill in the salary", Toast.LENGTH_LONG).show();
}
else
{
salarys = Double.valueOf(Salary.getText().toString());
if(salarys>=0 && salarys<=800000){
netsalary salarys ;
tax = 0;
}else if(salarys >= 800001 && salarys <= 1250000){
tax = (salarys *0.05)-40000;
netsalary salarys -((salarys *0.05) - 40000);
}else if(salarys >=1250001 && salarys <= 8500000){
tax = (salarys *0.1)-102500;
netsalary  salarys  - ((salarys  *0.1 ) - 102500);
}else if(salarys >= 8500001 && salarys <= 12500000){
tax = (salarys *0.15)-527500;
netsalary  salarys - ((salarys *0.15)-527500);
}else {
tax = (salarys *0.2)-1152500;
DecimalFormat df = new DecimalFormat("00.00");
                   String myre = df.format(tax);
netsalary  salarys - ((salarys *0.2)-1152500);
DecimalFormat dfo = new DecimalFormat("00.00");
                   String myreo = dfo.format(netsalary  );
}
}
String finaltax = String.valueOf(tax);
Tax.setText(" Pay tax = "+finaltax);
NetSalary.setText("Your Balance = "+ String.valueOf(netsalary  ));
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

Android Concept Sample Project

Android Concept Sampe Project 

In this tutorial you will know android project concept and this project name is tax on salary..
Some Countries get from citizen who is working in company or NGO and tax will automatically to government monthly . so this this tutorial we will create new android sample project it s name tax on Salary


Example: Cambodia (Tax on Salary)

Monthly salary (Riels)Rate
0 - 800,0000%
800,001 - 1,250,0005%
1,250,001 - 8,500,00010%
8,500,001 - 12,500,00015%
12,500,001 - upwards20%


Next tutorial we will create this sample android project.

Kategori

Kategori