Reputation: 1706
I'm making a View
by inflating an xml layout:
LayoutInflater inflater = (LayoutInflater) getBaseContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=inflater.inflate(com.example.R.layout.aaa, null);
in aaa.xml I have a RelativeLayout
that itself includes a TextView
and a Button
. now how can I access to that TextView
on view object?
Upvotes: 1
Views: 97
Reputation: 13705
First of all the TextView you are trying to reach must have an id (e.g. @android:id="@+id/yourTxtId"), and then from your rootView, in your case the View you are actually inflating all you have to do is:
View view=inflater.inflate(com.example.R.layout.aaa, null);
TextView txt = (TextView)view.findViewById(R.id.yourTxtId);
//And here you have the reference...
Regards!
Upvotes: 1