android-tablayout

Inflating AppBarLayout with Toolbar + TabLayout

北慕城南 提交于 2019-12-02 16:18:29
I currently have a DrawerLayout in my main.xml. There's a Toolbar wrapped in an AppBarLayout, and then a simple LinearLayout to swap out fragments. One of the fragments I navigate to, I want it to contain a TabLayout for a ViewPager of fragments. Currently, I have both of these in the fragment's layout file, but this causes a drop shadow to appear between the Toolbar and the TabLayout, which is something I don't want. I also don't want to use setElevation() because it won't work for pre-Lollipop devices. A possible solution would be to inflate the AppBarLayout from my fragment, so that it

updating data on viewpager change and tablayout click creates conflicts

我怕爱的太早我们不能终老 提交于 2019-12-02 09:11:07
I have already asked a question about my issue, but I didn't get any proper solution, so I am adding the whole details here. In my Activity, there is TabLayout and viewpager. On creating the activity, it fetch data from server and from that data it adds tabs dynamically. I am using single fragment for each tabs in a way that data corresponding to each tab will be populated in the list view in the fragment which will be shown in the view pager below tab layout.When directly clicking on the tab layout titles, data changes correctly. But when swiping the viewpager, it works, but for a small

Stop Android TabLayout loading next page automatically

折月煮酒 提交于 2019-12-02 04:54:01
I've realized when using a tab layout in Android it always loads the tabs touching it, i.e. the tab before and the tab after so it is loaded when you page to it. However, I load lots of content and images from a server and this causes a lot of data and memory use and I often get OOM errors , I am displaying the images efficiently using Glide. Basically I need to know 3 things: How can I stop the tab layout loading any pages other than the current one How to clear/recycle/delete an old tab after you get to a new page to clear up memory How to always refresh the tab when you go back to it By

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:

Got Error inflating class android.support.design.widget.TabLayout

非 Y 不嫁゛ 提交于 2019-12-01 20:20:31
I'm trying to create a menu tab based on Google's "material design" using Eclipse, but I got an error: 01-07 01:02:10.238: E/tag(6696): contact on create called 01-07 01:02:10.301: E/AndroidRuntime(6696): FATAL EXCEPTION: main 01-07 01:02:10.301: E/AndroidRuntime(6696): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rvappsstudios.designflashalerts/com.rvappsstudios.designflashalerts.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rvappsstudios.designflashalerts/com.rvappsstudios.designflashalerts.Contact_mainfragment}: android.view

is there any-way to use SpannableString in TabLayout?

别来无恙 提交于 2019-12-01 17:46:55
I want to set the title of the TabLayout with two different text sizes. Like the given image below. Or the other way around to achieve this! I have tried with SpannableString like give below. This snippet is in the for loop till 5! SpannableString mSpannableString= new SpannableString(s); mSpannableString.setSpan(new RelativeSizeSpan(2f), 0,5, 0); // set size mSpannableString.setSpan(new ForegroundColorSpan(Color.RED), 0, 5, 0);// set color mTabLayout.getTabAt(i).setText(mSpannableString); But as mentioned by CommonaSware setText() is not taking the rich content! TabLayout 's default style for

I need to assign a unique tab id to my tabs created using viewpager and tablayout?

不打扰是莪最后的温柔 提交于 2019-12-01 17:34:40
I created an Tab based application using viewpager and Tablayout. When i click a button new tabs are created with a child fragment. What I need is to assign different tab id to my tabs and each should be different. I tried i take the position of tabs but unfortunately, it doesn't work. when i tried to toast the position using below code it works only initially when the first tab is created and doesn't work for other tabs created. I don't know why this happens. ALso if i delete the tabs the position is not getting correct. So I need an alternative solution to assign a TAB id (number or name) to

FragmentManager is already executing transactions after using method setOffscreenPageLimit()

随声附和 提交于 2019-12-01 14:06:14
问题 i have a navigation drawer with a number of fragments and one of them is a tablayout with two recyclerview fragments , the RecyclerView items disappear after switching between navigation drawer fragments , i found a solution that i need to use method setOffscreenPageLimit() with the ViewPager but it gives me the bug that is mentioned in the question title here is my logcat java.lang.IllegalStateException: FragmentManager is already executing transactions at android.support.v4.app

How to create dynamic tabs and add different functionality to each fragment in Android?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 13:38:50
I knew how to create static Tabs, work with a volley to get data in android and work in each fragment but how to create dynamic tabs using JSON and store different details on each of tabs . Like first tab store "मुख्य समाचार" images and details which are coming from different web service. What I know is to create tabs like this: public class TabActivity extends AppCompatActivity { private Toolbar toolbar; private TabLayout tabLayout; private ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity

Android Studio, Trying to hide TabLayout, StatusBar, SupportActionBar and an unknown bar?

白昼怎懂夜的黑 提交于 2019-12-01 12:51:40
So at the click of a button I want to hide all bars on top of screen, to disappear. At another click of button I want them all to reappear again. I successfully did that and have the following bars to hide on button click: Status Bar, TabLayout tab fragments, Support Action Bar. Here's what I have. When I click my "Start" button ^, all these bars on top, hide. But only 1 is left ... I tried hiding the "getActionBar" but that bar that's left is not it. According to my styles.xml when I change the color of the 'ColorPrimaryDark', that's the bar that's left: I tried hiding PopupOverlay and