<Android> 7. Make a Calculator application
by BFineCalculator 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) {
실행
'공부(2018~2019) - 스킨변경전 > Android' 카테고리의 다른 글
<Andriod> 9. Intent, TabView (0) | 2018.04.26 |
---|---|
<Android> 8. ImageView, MapView (0) | 2018.04.24 |
<Android> 6. xml (0) | 2018.04.19 |
<Android> 5. ConstraintLayout, FrameLayout (0) | 2018.04.17 |
<Android> 4. RelativeLayout,TableLayout, ScrollView (0) | 2018.04.17 |
블로그의 정보
57개월 BackEnd
BFine