Reputation: 91
I have an application with three tabs. Under each, I'd like to be able to do things such as add buttons and/or TextViews
to add functionality or show content. I have set up tabs using TabsPagerAdapter
, and they all work fine. I have added button and TextView
elements to the xml
file for a tab, but when I try to connect them using findViewById
, I get errors because the class is not an activity class.
How do I get app functionality under a tab?
Upvotes: 1
Views: 136
Reputation: 38168
As @Ahmed Hafez suggested you can use your root view in your fragment or use, from your fragment as well :
getActivity().findViewById().
Both would work. The first option is a little more precise in case 2 view share the same id (which would not be a very good pactice).
Upvotes: 1