2012-03-26 1 views
13

나는 맞춤형 어댑터를 사용하여 ExpandableListActivity를가집니다.확장 가능한 목록보기의 버튼 android

어댑터의 사용자 정의 행에 imageViewall이 포함되어 있지만이 뷰를 imageView에서 imageButton으로 변경하면 확장 가능한 목록 뷰가 확장되지 않습니다.

클릭 할 수있는 버튼을 넣을 수있는 방법이 있습니까? 확장형 목록은 확장 기능을 잃지 않습니다.

답변

19

단추는 초점을 맞추어서는 안됩니다. (안 XML 레이아웃에서!) 당신의 listView.setOnItemClickListener에서 :

Button button = (Button) view.findViewById(R.id.yourButton); 
//where button is the button on listView, and view is the view of your item on list 

button.setFocusable(false); /// THIS IS THE SOLUTION 

button.setOnClickListener(new Button.OnClickListener() { 
    public void onClick(View v) { 
     //button functionalty ... 
    } 
}); 
+0

감사합니다. 당신을 위해 걱정하지 마세요 영어, 내 것이 더 나쁩니다.) – thenosic

+0

(Buttom)은 (버튼)이어야합니다 – pahan

+1

android에 대한 또 다른 힘의 순간 –

1

당신은 적어도 나를 위해 일하고,뿐만 아니라 '포커스'는 단지 클래스에없는 속성 만 XML에 설정할 수 있습니다.

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:focusable="false"/>