Skip to content

Instantly share code, notes, and snippets.

@mubin986
Created April 22, 2020 13:45
Show Gist options
  • Save mubin986/cfe16d050a40d09736e931577637572b to your computer and use it in GitHub Desktop.
Save mubin986/cfe16d050a40d09736e931577637572b to your computer and use it in GitHub Desktop.
package com.ishtiaq.calculator;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
/*
* This is our Logic file (.java)
* */
// this super
public class MainActivity extends AppCompatActivity {
TextView tv1;
EditText et1, et2;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // আমরা View কে চিনিয়ে দিলাম
// Start your own code from here
tv1 = findViewById(R.id.myDisplay);
et1 = findViewById(R.id.inputA);
et2 = findViewById(R.id.inputB);
btn = findViewById(R.id.myBtn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doMath();
}
});
}
void doMath()
{
int x = Integer.parseInt(et1.getText().toString());
int y = Integer.parseInt(et2.getText().toString());
int z = x + y;
tv1.setText("Ans: " + z);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment