0

子に2つのボタンが含まれるexpandableListViewをAndroidで作成しました。

これらのボタンのactionlisternerは別のクラスにあります。子ビューのボタンがクリックされたときにactionListenersが呼び出されるようにするにはどうすればよいですか?

これは私がやろうとしたことです:

  public View getChildView(int groupPosition, int childPosition,
    boolean isLastChild, View convertView, ViewGroup parent) {

   if (convertView == null) {
    LayoutInflater inflater =  (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = inflater.inflate(R.layout.childrow, null);
    Button b1 = (Button) convertView.findViewById(R.id.button1);
    Button b2 = (Button) convertView.findViewById(R.id.button2);


    classWithListeners p = new ClassWithListeners(b1,b2);

}

4

1 に答える 1

0

ClassWithListeners に、リッスンする任意の actionListener を実装させます (つまり、onClickListener)

そして、する

ClassWithListeners p = new ClassWithListeners(b1,b2);
b1.setOnClickListener(p);
b2.setOnClickListener(p);
于 2012-04-06T12:38:30.757 に答える