How to set an onClickListener on an included layout?

后端 未结 3 1850
刺人心
刺人心 2021-01-02 11:52

I have a layout with an ImageButton that I included in several other layouts.

ImageButton Layout:

call_cancelled.xml

3条回答
  •  死守一世寂寞
    2021-01-02 12:11

    You could have done

    LinearLayout endcall0 = (LinearLayout) findViewById(R.id.includeCallEnd0); 
    

    and then simply

    ImageButton imgBtn = (ImageButton) endcall0.findViewById(R.id. phoneEnd); 
    imgBtn.setOnClickListener(this);
    

提交回复
热议问题