android-tabs

findFragmentById always returns a null

旧时模样 提交于 2019-12-01 22:18:10
问题 I'm using an actionbar in navigation mode in the mainActivity. Different tabs has different layouts, and on one of these tabs, I embed a layout which has a MapFragment inside. With the following code, the app works well, the mapFragments works fine, the tabs works fine. However, once I want to get access the mapFragment embeded in myFragment use getFragmentManager().findFragmentById(R.id.map_add), I always get null. I've tried using FragmentManager and FragmentTransaction to add myfragment

Temporarily/Dynamically disable single page in Viewpager

二次信任 提交于 2019-12-01 21:08:04
I have an extended FragmentPagerAdapter that provides 3 fragments to a ViewPager, giving me 3 pages that I can either swipe between or use the tabs I've added to the actionbar to manually choose a page. I'd like to temporarily disable the user from accessing the final page (a more generalized solution to disable any specific page would also be interesting, but not necessary) with either navigation type. I will then re-enable their access with a callback from one of the fragments. I've read through answers to some similar questions about not allowing swiping by overriding onTouchEvent and

Check fragment visibility after clicking on Tab from TabLayout that only contains icon using Android Espresso

拟墨画扇 提交于 2019-12-01 20:33:50
I'm trying to check if my fragment is visible after performing a click on my tab from my tabLayout which has been set up with view pager. This is my actual activity code, inside my activity onCreate method: mViewPager = findViewById(R.id.contentFrameLayout); mViewPager.setAdapter(mSectionPageAdapter); mViewPager.setPagingEnabled(false); //Set up the tab layout to display tabs tabLayout = findViewById(R.id.homeTabs); tabLayout.setupWithViewPager(mViewPager); for (int i = 0; i< tabLayout.getTabCount(); i++) { TabLayout.Tab mTab = tabLayout.getTabAt(i); if (mTab != null) { switch (i){ case 0:

Android Tabs in middle of layout

不打扰是莪最后的温柔 提交于 2019-12-01 08:09:55
In the middle of my layout I want to have 2 tabs to choose between viewing 2 different lists in the second half of the screen. How can I do this? Here is an image illustrating what I wish to achieve. This image has a questions tab and an answers tab in the middle of the screen. Depending on which tab you select it shows a different listview: I wish to achieve this exact same thing. I tried doing it with TabHost widget, but for the life of me I couldn't get rid of the title bar (I tried selecting themes with no title bar, tried setting the theme in the manifest to a no title bar one) I also

Android Actionbar set width to the tabs

我只是一个虾纸丫 提交于 2019-12-01 04:46:34
Currently I'm busy on a WHMCS app for my company. As navigation I want to use the Tab functionality in the actionbar. However, how can you edit the width of a tab? I need 5 together on one screen without the need to scroll. I already tried it with some styles like this: <style name="AppBaseTheme" parent="android:Theme.Light"> </style> <style name="AppTheme" parent="AppBaseTheme"> <item name="@android:attr/actionBarTabStyle">@style/tab_nav</item> <item name="android:actionBarTabTextStyle">@style/actionBarTabTextStyle</item> </style> <style name="actionBarTabTextStyle" parent="android:Widget

Android: How to change android:fillcolor with selector in one Vector Drawable xml

浪子不回头ぞ 提交于 2019-12-01 04:25:49
Tab Icons: My current method is to create two files (ic_list_selected_24dp.xml and ic_list_unselected_24dp.xml; they are basically the same but only the android:fillColor='Color HEX CODE' are different), and then create a selector (selector_tabitem_list.xml) to change the drawable color when the state is changed. // @drawable/selector_tabitem_list.xml <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:drawable="@drawable/ic_list_selected_24dp" android:state_selected="true" /> <item android:drawable="@drawable

Sliding tab layout text is uppercase

て烟熏妆下的殇ゞ 提交于 2019-12-01 01:52:57
问题 Hi I'm using Sliding tab layout in my app and it all works great. The only thing I dont understand is why my tabs text are in uppercase. I've printed the text the tabs get inside of the sliding tab class and they are not in uppercase. I've looked around and there is no toUpperCase method being called. Here is the code from the class that sets the text: private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new

Add Image or style to each tab

萝らか妹 提交于 2019-12-01 01:50:29
i have app with many tabs, i want to add image or style to each tab , how please? th = (TabHost) findViewById(R.id.tabhost_template_two_tabs); th.setup(); // all tab spec = th.newTabSpec("All"); spec.setIndicator("All"); spec.setContent(R.id.tab_template_two_tabs_all); th.addTab(spec); // favorite tab spec = th.newTabSpec("Favorite"); spec.setIndicator("Favorite"); spec.setContent(R.id.tab_template_two_tabs_favorite); th.addTab(spec); th.setCurrentTab(1); Thanks Try this : Call this from your OnCreate() method: setTabs(); Then put this code private void setTabs() { addTab(R.drawable.ic_icon1,

Attempt to invoke virtual method 'void android.support.v4.view.ViewPager.setAdapter(android.support.v4.view.PagerAdapter)' on a null object reference

痴心易碎 提交于 2019-11-30 18:06:52
I'm trying to implement sliding tab layout using android material design. But it gives me NullPointerException . Here is my code so far: MainActivity.java public class MainActivity extends ActionBarActivity { private Toolbar toolbar; private ViewPager pager; private SlidingTabLayout nLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_appbar); toolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowHomeEnabled(true); NavigationDrawerFragment

What event is triggered when a tab fragment is selected

徘徊边缘 提交于 2019-11-30 11:29:28
I'm using tab fragments in an activity and the actionbar hosts the tabs. What I want to do is that whenever a fragment appears (or re-appears) in the view (selected by the user), I start doing something. I cannot use onResume of the fragment in this case, since all tabs are never really 'paused' when the user selects another tab, so onResume is not called I can use the two following events from the hosting activity, but I don't want them since I expect the fragment should know this logic on its own and do that task. Any idea? tks. @Override public void onTabSelected(ActionBar.Tab tab,