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

버튼 이미지 변경하려고하는데요

0 추천
액티비티 1에서 버튼을 두고 액티비티2에 버튼이미지를 변경하고 저장하려고합니다.

액티비티1 코드는

mClear.setOnClickListener(new OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent intent = new Intent(Place_Gyeongbok_Gyeonghoeru.this,
      Choice_Acourse_Activity.class);
    SharedPreferences.Editor editor = setting.edit();
    editor.putInt("Gyeonghoe", R.drawable.ic_launcher);
    
    startActivity(intent);
   }
  });

이고 버튼을 누르면 프리퍼런스에 Gyeonghoe 키 값으로 이미지를 저장을한상태로 액티비티2를 실행하고

액티비티2 코드는

pic=setting.getInt("Gyeonghoe", R.drawable.left);
  
  if(pic == R.drawable.left){
   mGyeonghoe.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.left, 0, 0);
   mGyeonghoe.setBackgroundColor(Color.alpha(0));
  }else{
  mGyeonghoe.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_launcher, 0, 0);
  mGyeonghoe.setBackgroundColor(Color.alpha(0));
  }

이렇게 pic에 받아놓고 쓰려고 하는데 액티비티 버튼이미지 변화가 일어나질 않네요;;

어떻게해야할까요..
부개동지킴이 (590 포인트) 님이 2013년 11월 10일 질문

1개의 답변

0 추천
혹시 첫번째 액티비티에서 프레프런스에 put한뒤에 commit 하신건가요?
이스트플랙 (2,510 포인트) 님이 2013년 11월 11일 답변
저도 그걸 깜빡했네요ㅋㅋㅋㅋ
...