android-viewpager

getActivity from fragment inside View pager return null

有些话、适合烂在心里 提交于 2021-02-19 06:15:11
问题 I have a View pager inside of Fragment Activity and the View pager Contain two fragment at the start of the activity i have a rest request and when i get the response i want to update the Views inside of each fragment and in each one i'm using getActivity but my problem is the i always get null pointer exception on getActivity just on tablet Devices but i didn't get this issue on mobile phones that's my pager adapter public class Guide_ViewPager_adapter extends FragmentStatePagerAdapter {

Alternative of TabHost

自闭症网瘾萝莉.ら 提交于 2021-02-13 17:36:18
问题 Here as you can see I used TabLayout , TabHost . I used TabLayout in first twice pictures. In third picture I used TabHost . Usually, TabLayout is looking better than TabHost / TabWidget .TabHost as you can see TabHost is deprecated. So, It would be better if I don't use TabHost . TabLayout isn't deprecated. Here is a question I asked someone said it is duplicate. I thought it was. Look, while I am using ViewPager and TabLayout I can't use those layout directly in MainActivity I meant I have

Alternative of TabHost

一个人想着一个人 提交于 2021-02-13 17:34:03
问题 Here as you can see I used TabLayout , TabHost . I used TabLayout in first twice pictures. In third picture I used TabHost . Usually, TabLayout is looking better than TabHost / TabWidget .TabHost as you can see TabHost is deprecated. So, It would be better if I don't use TabHost . TabLayout isn't deprecated. Here is a question I asked someone said it is duplicate. I thought it was. Look, while I am using ViewPager and TabLayout I can't use those layout directly in MainActivity I meant I have

Alternative of TabHost

喜欢而已 提交于 2021-02-13 17:33:11
问题 Here as you can see I used TabLayout , TabHost . I used TabLayout in first twice pictures. In third picture I used TabHost . Usually, TabLayout is looking better than TabHost / TabWidget .TabHost as you can see TabHost is deprecated. So, It would be better if I don't use TabHost . TabLayout isn't deprecated. Here is a question I asked someone said it is duplicate. I thought it was. Look, while I am using ViewPager and TabLayout I can't use those layout directly in MainActivity I meant I have

Too late to create Fragments?

僤鯓⒐⒋嵵緔 提交于 2021-02-11 17:21:30
问题 I am working on my first Android application. I just came to discover Fragments and I need them to create a ViewPager to create nice transitions between my activities, but I fear that it's too late to implement that. I have to put all my code ( MainActivity ) in my MainFragment? Or just some pieces I don't know what I have to keep in my MainActivity Here is my code public class MainActivity extends FragmentActivity { ObjectAnimator anim; ObjectAnimator anim2; private int display, result,

Fixed number of tabs per page in TabLayout

房东的猫 提交于 2021-02-11 14:31:00
问题 I am using scrollable TabLayout with a ViewPager. I want to make sure that at any given time I have 7 tabs displayed per page. Even if the total number of tabs is 10, I want to have 7 per page, and scroll to expose the other 3. I can't find a property to control the number of tabs displayed. 回答1: Eventually what worked for me was to calculate the desired size of each cell to get the total amount of tabs that I needed per page and set app:tabMaxWidth inside android.support.design.widget

Fixed number of tabs per page in TabLayout

亡梦爱人 提交于 2021-02-11 14:29:35
问题 I am using scrollable TabLayout with a ViewPager. I want to make sure that at any given time I have 7 tabs displayed per page. Even if the total number of tabs is 10, I want to have 7 per page, and scroll to expose the other 3. I can't find a property to control the number of tabs displayed. 回答1: Eventually what worked for me was to calculate the desired size of each cell to get the total amount of tabs that I needed per page and set app:tabMaxWidth inside android.support.design.widget

Viewpager2 transistion stuck halfway when slide opened using setCurrentItem

只谈情不闲聊 提交于 2021-02-10 07:37:08
问题 The app uses android viewpager2 (androidx.viewpager2:viewpager2:1.0.0-beta04) to show slides. Each slide have video on its top half and text on its bottom half. Each slide is built using same fragment class (code given below) If slided one by one, slide show works absolutely fine, however if attempted opening 'setCurrentItem', SOMETIMES slide stucks halfway in transistion as shown in image below. Presentation Activity myViewPager2.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);

SwipeRefreshLayout and Vertical ViewPager Touch Issues

梦想与她 提交于 2021-02-08 10:18:35
问题 I have a Activity with Custom SwipeRefreshLayout and a Vertical ViewPager which swipes vertically. (basically a deck of cards which can be refershed by using swipe to refresh). So Now when i try to swipe the Vertical Viewpager SwipeRefreshLayout handles the touch event and refresh the layout and the view pager's page does't move. Two things i tried but with no luck: Enable swipe to refresh layout only when user starts from the toolbar. MotionEvent.ACTION_DOWN event getY() gives toolbar's y

ViewPager findViewById is null after screen rotation in android

风格不统一 提交于 2021-02-08 10:17:30
问题 I'm using a viewPager to display some forms. My problem is when i rotate the screen of the device and the viewPager is created again, it doesn't see the viewPager when he reaches the findViewById , it's always null . I have no idea how to handle it when rotation change. I tried the onConfigurationChange but it doesn't work, I tried to save the Id of the pager and then retrieve it using that saved id but nothing too. So I'm quite blocked now. pager = (CustomViewPager) getActivity()