my name augusto, i'm developing messaging/social app android on android studio , implemented slidingtablayout (com.google.samples.apps.iosched.ui.widget) 2 tabs (chats , friends ).
i wish know how access views inside tabs' xml files on activity.
i have: mainactivity.class activity_main.xml contentview , tabs's layouts(friendsview.xml , chatsview.xml) tabs.
i want access tabs' layouts view (e.g: edittext, imageview) mainactivity.class, how "import" them activity?
thanks!
slidingtablayout it's layout. manage content use fragments fragmentpageradapter tabs.
here (link) nice tutorial you.
if follow example tutorial, have
public class tab1 extends fragment { @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view v =inflater.inflate(r.layout.tab_1,container,false); return v; } } and access edittext , other widget inside tab, need have reference view, change above code to:
public class tab1 extends fragment { private edittext edittext; @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view v = inflater.inflate(r.layout.chatsview,container,false); edittext = v.findviewbyid(r.id.your_edit_text_id); return v; } }
Comments
Post a Comment