2014-07-07 6 views
2

Android 애플리케이션을 개발 중이며 다른 활동을 시작하는 버튼이 있습니다. 버튼이 첫 번째 클릭에 응답하지 않지만 후속 터치에 응답합니다. 해당 버튼에 대한 XML버튼이 첫 번째 클릭에 응답하지 않습니다.

<Button 
    android:id="@+id/bonePArenaplay" 
    android:layout_width="160dp" 
    android:layout_height="90dp" 
    android:layout_alignLeft="@+id/bmainleaderboard" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="200dp" 
    android:background="@drawable/arenabtnback" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:gravity="center|bottom" 
    android:padding="10dp" 
    android:shadowColor="@android:color/white" 
    android:shadowRadius="25" 
    android:text="Play" 
    android:textColor="@android:color/white" 
    android:textSize="20sp" /> 

자바 코드 : -

public class MainActivity extends FragmentActivity implements OnClickListener 
    { 

    protected void onCreate(Bundle savedInstanceState) { 
    .... 

    bonePArenaplay = (Button) findViewById(R.id.bonePArenaplay); 

    bonePArenaplay.setOnClickListener(this); 
     ..... 
    }  

@Override 
public void onClick(View arg0) { 
    // TODO Auto-generated method stub 
    Animation anim2 = AnimationUtils.loadAnimation(this, R.anim.clickanim); 
    Log.d("clicked", "called"); 
    switch (arg0.getId()) { 

    case R.id.bonePArenaplay: 

     bonePArenaplay.setAnimation(anim2); 
     bonePArenaplay.startAnimation(anim2); 
     Intent i = new Intent(this, GenreActivity.class); 
     i.putExtra("Mode", 1); 
     startActivity(i); 
     break; 
    .... 

지금 주일 이상 대답을 시도하고 헛된

의 모든 유래에 대답하지만, 모두 살펴 보았다

그리고이 문제는 내 응용 프로그램의 모든 버튼에 복제됩니다. 모든 활동은 첫 번째 터치에 응답하지 않지만 후속 작업에는 응답합니다. 어떤 도움을 주셔서 감사합니다.

일부 솔루션은 내가 시도 : -

1 setonclicklistener은 한 OnCreate

2에 아직도 영향을 OnClickListener를 호출하지하는 ontouchlistener 설정을 시도

+0

에뮬레이터 또는 실제 하드웨어 장치에서 테스트 중이십니까? 그것은 둘 중 하나의 잘못 일 수 있습니다. – rageandqq

+0

실제 장치에서 테스트 중이며 시도한 다른 장치에서 문제가 지속됩니다. – user3387193

+0

OnClickListener에 대한 코드를 게시 할 수 있습니까? – rageandqq

답변

0

android:focusable="false" 

를 제거 현재 포커스를 맞출 수 없기 때문에 첫 번째 클릭은 버튼 포커스를 제공합니다.

+0

문제가 지속되면 – user3387193

+0

코드 스니 j은 어떤 f}입니까? 어떤 반에서? – Floris

+0

이 관련 클래스로 질문을 업데이트했습니다. – user3387193

관련 문제