Saeid Z
Saeid Z

Reputation: 407

Can i access the child's of included layout directly by findViewById() method in android?

Can i access the Child's of included layout that included the main activity layout, directly by findViewById() method in main activity?

Upvotes: 3

Views: 2344

Answers (3)

Nguyễn Gia Lễ
Nguyễn Gia Lễ

Reputation: 357

You can totally access child by findViewById. When you include one layout in other layout, it's same when you code inside.

Upvotes: 0

debugger
debugger

Reputation: 640

Yeah this way.

//in XML 
    <include layout="@layout/extLayout" 
    android:id="@+id/myLayout" />

//in Activity 
    View view= findViewById(R.id.myLayout);
    Button button= (TextView) view.findViewById(R.id.button);

Upvotes: 4

Mehul Kabaria
Mehul Kabaria

Reputation: 6622

yes you can access that included layout in activity layout using findValueById()

Upvotes: 0

Related Questions