You will be fine

<Android> 7. Make a Calculator application

by BFine
반응형

Calculator Ver1.0


<메뉴 화면 전환>
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button button=findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(getApplicationContext(), Calc.class); // 넘길 클래스
startActivityForResult(intent,1);
}
});

}
}

<계산 구현>

 protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calc);

editText = findViewById(R.id.editText);

arrayList = new ArrayList();
button7 = findViewById(R.id.btn7);
button8 = findViewById(R.id.btn8);
button9 = findViewById(R.id.btn9);
button4 = findViewById(R.id.btn4);
button5 = findViewById(R.id.btn5);
button6 = findViewById(R.id.btn6);
button1 = findViewById(R.id.btn1);
button2 = findViewById(R.id.btn2);
button3 = findViewById(R.id.btn3);
button0 = findViewById(R.id.btn0);
plu = findViewById(R.id.puls);
sub = findViewById(R.id.sub);
mul = findViewById(R.id.mul);
div = findViewById(R.id.div);
c = findViewById(R.id.c);
par1=findViewById(R.id.par1);
par2=findViewById(R.id.par2);
AC=findViewById(R.id.ac);

result = findViewById(R.id.res);
}

public void onClick(View view) {

if(check_result==true){
editText.setText("");
check_result=false;
}

if (view == button9) {
arrayList.add(9);
editText.setText(editText.getText() + "9");
} else if (view == button8) {


실행

calc.apk


       


calc.apk

반응형

블로그의 정보

57개월 BackEnd

BFine

활동하기