android - How do i access a included layout in my code? -
so have included layout in xml file want included layout in code , add it.
you view
s using findviewbyid()
but don't think can used in case. part of xml referring
<include android:layout_width="350dp" android:layout_height="wrap_content" layout="@layout/progress_bar" android:layout_margintop="20dp" android:layout_below="@+id/instructions_label" android:layout_centerhorizontal="true" />
you views using 'findviewbyid'
but don't think can used in case
sure can. give included layout id
<include layout=@layout/somelayout android:id="@+id/myid" .../>
then retrieve id
view mylayout = (view) findviewbyid(r.id.myid);
then can use reference sub views somelayout.xml
button btn = (button) mylayout.findviewbyid(r.id.btn1)
assuming somelayout.xml
has button
id of btn1
Comments
Post a Comment