0
하나의 메뉴 버튼과 더 긴 state_pressed 상태 (0.5 초)를위한 모션 클래스가 있습니다. 잠시만 기다려도 문제는 없지만 한 가지 문제가 발생합니다.android "state_pressed"는 두 번째 시도에서만 작동합니다.
처음 버튼을 누르면 state_pressed가 처음 작동하지 않고 두 번째 시도에서 올바르게 작동하고 state_pressed가 0으로 작동합니다. 5 초 지속.
첫 번째 프레스에서 어떻게 작동합니까? tehre hover.xml 파일 및 setBackgroundDrawable 함께 문제가 생각하십니까?
미리 도움 주셔서 감사합니다!
이것은 당김 내 hover.XML
<?xml version="1.0" encoding="utf-8"?>
<item android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/buttonstyle_pressed" />
<item android:drawable="@drawable/buttonstyle" />
입니다 그리고 이것은 내 자바 코드
Button menubutton_start;
menubutton_start = (Button) FindViewById(R.id.menustart);
menubutton_start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
menubutton_start.setBackgroundDrawable(getResources().getDrawable(R.drawable.hover));
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
Intent myIntent = new Intent(GameActivity.this, NextActivity.class);
GameActivity.this.startActivity(myIntent);
}
}, 500); // end of Handler new Runnable()
} // end of OnClick()
}); // end of setOnClickListener
Eclipse 환경을 4.0.3으로 업데이트했으며이 오류가 다시 발생합니다. (2.2에서 작동했다) :-(도움을 청하던 중! – synthesis
이제는 최종적으로 문제가 해결되었는데, 이는 보통 버튼 위에 오버레이 된 background_img 이었으므로 프레스 _ 스테이트 상태는 첫 번째 프레스에서 ressource를 확인할 수 없었다. – synthesis