2013-05-04 2 views
2

백그라운드 리소스 체크를 어떻게 수행 할 수 있습니까?Android : 백그라운드 리소스 드로어 블 체크

예 :

Button button1; 

    protected void onCreate(Bundle savedInstanceState) { 
    .......................................... 
    button1 = (Button) findViewById(R.id.example1); 
    } 

    public void onclick1 (View v){ 
     button1.setBackgroundResource(R.drawable.example2); 
    } 

    public void onclick2 (View v){ 

여기 내 질문, 확인하는 경우 단추 1 버튼 당김 = 예 2

 if (..........................){ 
       //Action 
     } 

다른 작업을 수행합니다 클릭 할 때하지 않으면

 else { 
       //Another Action 
     } 
    } 

답변

4

당신은 사용할 수 있습니다 getBackground() 두 버튼에 대한 View 클래스의 메서드는 다음과 같이 비교합니다.

if (button1.getBackground().getConstantState().equals(button2.getBackground().getConstantState())) { 
    } 
else { 
    } 
+0

감사합니다. 작동합니다. – user2341387

관련 문제