마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 integer로 변환해서 체크박스 intent받기 [closed]

0 추천
 
intent로 checkbox가 체크된 textview를 Mainactivity에서 받아와서 그 
textview를 integer형으로 바꾸고, 체크된 textview의 integer값이 존재하면
 현재 acticity의 checkbox를 그대로 체크하려는 코드를 짜려는데,
int형으로 다음과 같이 바꾸고.. if문에 조건을 넣었는데 프로그램 실행해서
 checkbox를 mainacticity에서 체크하고 버튼을 누르는 순간 현재 activity로 
넘어오려는데 바탕화면으로 튕겨버리네요.. 예외처리가 문제인지 어디를 고쳐
야할까요..?
        Intent intent = getIntent();
//      Integer get_pilaf = intent.getIntExtra("pilaf",0);
        String get_pilaf = intent.getStringExtra("pilaf");
        String get_bread = intent.getStringExtra("bread");
        String get_all = intent.getStringExtra("all");
        String get_tomato = intent.getStringExtra("tomato");
        String get_cal = intent.getStringExtra("cal");

        tv_pilaf.setText(get_pilaf);
        tv_bread.setText(get_bread);
        tv_all.setText(get_all);
        tv_tomato.setText(get_tomato);
        tv_total.setText(get_cal);


//        int sum = 0;
        String a = tv_pilaf.getText().toString();
        int a1 = Integer.parseInt(a);
        if(a1 > 0) {
            checkBox_pilaf.setChecked(true);

//            int in = Integer.parseInt(a);
//            sum += in;
        }
 
 
질문을 종료한 이유: 해결되었습니다
쟈스믠 (120 포인트) 님이 2020년 10월 27일 질문
쟈스믠님이 2020년 10월 27일 closed
...