Android Bangla Tutorial 2.17 : EditText (part-2) personal blog

// ata sub ar work tar mane amora calculator make korte parbo

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements OnClickListener {

    private EditText editText, editText2;
    private Button addbutton, subbutton;
    private TextView textView2; // output pawar jonno aie text view use koro hoy
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        editText = (EditText) findViewById(R.id.likhon1);
        editText2 = (EditText) findViewById(R.id.likhon3);
        addbutton = (Button) findViewById(R.id.buttonidtext);
        subbutton = (Button) findViewById(R.id.buttonidtext25);
        textView2 = (TextView) findViewById(R.id.textide);

        addbutton.setOnClickListener(this);
        subbutton.setOnClickListener(this);

    }

    @Override    public void onClick(View v) {

        String name1 = editText.getText().toString(); // edittext ar modhe amora ki input niyechi seta ke kono akta veriable ar modhe niye nite hobe string a convert kore  nite hobe        String name2 = editText2.getText().toString();//edit text a amoro ki set korechilam seta kono akta veriable ar modhe rekhe debo
        double num = Double.parseDouble(name1); //stringgulo ke prothome double a convert kore note hobe        double num2 = Double.parseDouble(name2); // string ke ami sub and sum korbo na tai ami double a convert kore nile bhalo hobe sub and sum
        if (v.getId() == R.id.buttonidtext) { //
            double sum = num + num2;

            textView2.setText(" Result : " + sum);
        }

        if (v.getId() == R.id.buttonidtext25) {

            double sub = num - num2;

            textView2.setText(" Result : " + sub);


        }
    }
}

Produk Kami Lainnya :

Post a Comment

 
ibs(idblogsite)
Copyright © 2014. Background remove
Distributed By Blog Templates | Designed By Gusti Adnyana