2012-03-26 11 views
13

私はカスタムアダプタでExpandableListActivityを持っています。拡張可能なリストビューのボタンandroid

アダプターのカスタム行にimageViewallが含まれている場合、このビューをimageViewからimageButtonに変更すると、展開可能なリストビューは展開されません。

クリック可能なボタンを配置する方法はありますか?また、展開可能なリストには拡張機能が失われませんか?

答えて

19

ボタンには焦点が合わないようにする必要があります。あなたのlistView.setOnItemClickListenerでは(ないXMLレイアウトで!!):

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

もう1つの年齢はandroid –

1

あなたは「フォーカス可能な」を設定することができますクラスでだけではない属性が、同様に、XMLには、少なくともそれは私のために働いています。

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:focusable="false"/> 
関連する問題