How to access Button inside “include” layout

后端 未结 5 1711
不知归路
不知归路 2020-12-13 12:36

Refer to the doc: http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html

I have a button inside the included layout, how can I a

5条回答
  •  感动是毒
    2020-12-13 13:14

    All you need is the id of the parent view:

    In this example, the LinearLayout is the parent of the TextView I want from the included View.

    I can now do this:

        View view = findViewById(R.id.include_title_layout);
        TextView titleTV = (TextView) view.findViewById(R.id.newsTitleTextView);
        titleTV.setText("Whatever");
    

提交回复
热议问题