android-tablayout

IllegalStateException: Can't change tag of fragment was android:switcher now android:switcher

五迷三道 提交于 2019-12-04 16:21:04
问题 My activity uses TabLayout + ViewPager . The number of tabs and pages here are dynamic depending on the data fetch from the server. The crash are reported via Crashlytics, I'm not able to replicate it. My Activity code: @Override protected void onCreate(Bundle savedInstanceState) { boolean isAppRestarting = PrefUtils.getBoolean("app_restarting", false); if (isAppRestarting) { super.onCreate(null); this.savedInstanceState = null; } else { super.onCreate(savedInstanceState); this

How to scroll tablayout programmatically - Android

a 夏天 提交于 2019-12-04 15:42:22
问题 I have created 30 scrollable tabs using tablayout. So first three tabs are visible on screen and rest of them are invisible which can be scroll using swipe gesture. The problem is when I am selecting last tab programmatically but it is not get visible (tab layout not get scrolled to last tab). How can I make tablayout to scroll to last tab? 回答1: I found the solution. First I had found the width of tablayout and scroll it's x position to width and than called the select() method of last tab.

Communication from Activity to Fragment with ViewPager

情到浓时终转凉″ 提交于 2019-12-04 10:50:01
I have one Activity and two Fragments for a tablayout containing a viewpager . Now I can communicate from the fragment to the Activity by implementing the google's guide callback interface. But how can I communicate the other way from activity to fragment ? If something happens in the Activity (external events) I want to update the Fragment. I managed to get the Frag1 fragment with MyFragmentPagerAdapter a = (MyFragmentPagerAdapter) viewPager.getAdapter(); Frag1 frag = (Frag1) a.getItem(0); but when I call public methods on frag I get a IllegalStateException: Fragment not attached to Activity

Why is Tablayout and Viewpager crashing with NullpointerException when I start a fragment with LoaderManager from TabFragment?

◇◆丶佛笑我妖孽 提交于 2019-12-04 10:23:00
I am following the tutorial of https://androidbelieve.com/navigation-drawer-with-swipe-tabs-using-design-support-library/ to implement sliding tablayout. It works perfect for empty fragments, However, I have 3 fragments with LoaderManagers and recyclerViews, each one loads different data. When the app loaded at the first time, if I click from the first fragment to the third fragment on the tabLayout without sliding or clicking to second one, it crashes. The data was not loading, as it implements LoaderManager, it started implementing from OnLoadFinished() method. I couldn't see onCreate().. or

CoordinatorLayout + TabView + AnimateView(From Top)

和自甴很熟 提交于 2019-12-04 08:30:53
问题 Yesterday I am playing with CoordinatorLayout with TabView 1) What is my target ? CoordinatorLayout with TabView When I scroll up at that time One View As show in .GIF move down . and Stick on the Top of the TabView (inside AppBar). 2) Where I reached ? CoordinatorLayout with TabView with pretty scrolling. TabView with Appbar Stop Scrolling At Top after Then Scroll RecyclerView. 3) Where I stuck ? When I scroll Up One View Scroll Down but TabView Stick At Top not like 1st gif . 4) Code

TabLayout using activities instead of fragments

送分小仙女□ 提交于 2019-12-04 07:16:15
Is it possible to create a swiped TabLayout in an app using multiple activities instead of fragments? I have two activities using which I am trying to create an app that uses a swipable TabLayout. I am searching the net over this but could not find one yet. If that is possible to build, can anyone please provide some links or tutorials over this? yennsarah From GestureDetector and OnSwipeTouchListener : public class MainActivity extends Activity { private GestureDetectorCompat mDetector; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

TabLayout Indicator customization

坚强是说给别人听的谎言 提交于 2019-12-04 07:02:36
i have been searching how to change the indicator in Tablayout to be circular, like this but i don't know how to do so, any help! From the source code , the tab indicator is defined as: <style name="Base.Widget.Design.TabLayout" parent="android:Widget"> <item name="tabMaxWidth">@dimen/design_tab_max_width</item> <item name="tabIndicatorColor">?attr/colorAccent</item> <item name="tabIndicatorHeight">2dp</item> <item name="tabPaddingStart">12dp</item> <item name="tabPaddingEnd">12dp</item> <item name="tabBackground">?attr/selectableItemBackground</item> <item name="tabTextAppearance">@style

How sync TabLayout with ViewPager when using TabItem

孤人 提交于 2019-12-04 06:40:25
I want to use TabLayout with TabItem with following code: <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/color_primary" app:tabGravity="fill" app:tabIndicatorColor="@color/white" app:tabMode="fixed" app:tabSelectedTextColor="@color/white" app:tabTextColor="@color/gray_light"> <android.support.design.widget.TabItem android:layout_width="wrap_content" android:layout_height="match_parent" android:icon="@drawable/ic_language" /> <!-- other tabs ... --> </android.support.design

Android how to hide tab from TabLayout

随声附和 提交于 2019-12-04 05:57:30
I need to hide first tab. First page should work but when user select it, it should be seems like on tabs is selected. How I can do this? I found some solutions with TabHost and it useless to me. public class TabFragmentClients extends Fragment { public static TabLayout tabLayout; public static ViewPager viewPager; public static int int_items = 5 ; FinanceClients FinanceClients; public ClientsFragment clientsFragment; public FinanceFragment financeFragment; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { /** *Inflate tab

Different tabMode for TabLayout

眉间皱痕 提交于 2019-12-04 04:29:54
I`m using ViewPager and TabLayout. If tabs can be placed on the display tabMode they must be: app:tabMode="fixed" else app:tabMode="scrollable" How can I do this? Ram Prakash Bhat I din't get your question but i may help you, if tabs count is static or fixed(you know number of tabs) then app:tabMode="fixed" if tabs count is dynamic(data coming from feed) then app:tabMode="scrollable" If the problem is that for certain screen configurations (e.g. small screens, portrait config, etc.) the tabs need to be scrollable because they don't fit the screen and, for other screen config/sizes the number