Hi,
I implemented sliding tab layout using Google's SlidingTabLayout. The position of tab changes on swiping View pager , but View pager does not refresh on scrolling Tabs like the way we see in contacts application where the user scrolls the tab and the View pager corresponding to particular tab also changes . Is there a way in which we can customize this in SlidingTablayout ? can anyone help me in sorting out this issue ?
Thanks in advance.
You need to update content of fragment in onResume to ensure that content is updated.
Related
Currently I have a RecyclerView which upon creation is populated by a list of movies stored in an SQLite DB. Every movie has a genre that can be set by the end user.
I want to be able to set-up dynamic tabs for each genre that users can swipe through for easier access as the dataset grows. I was just at a loss for where to start. Any help is appreciated. Thank you.
TabLayout is where you should start.
You can use addTab() for dynamic tab creation.
TabLayout is made to work well with ViewPager. When you use the setupWithViewPager() method, the two are set up with corresponding event listeners, so that swiping in the ViewPager sets the tab active, and selecting the tab goes to that tab's page in the ViewPager.
I think you can start with ViewPager and use RecyclerView in its fragments.
I am trying to achieve UI shown as below.
Header which can be included in xml,same goes to search text view as it is a reusable view. Problem I am facing is to make tab view , each having list item and as usual tabs should be slidable. I am planning to use base class which extends android.support.v4.app.FragmentActivity
At the end there is a footer also. Below is the UI which I am trying to achieve. Any help is really appreciable.
Have a look at ViewPager. This will handle the sliding.
For the tabs, you can use the good ol' TabWidget or the new TabLayout from the Design Support library
once again, I am following this tutorial: androidhive - tab layout with swipe able views . All 3 fragment tabs are loaded with different information and logic and layouts. I would like to refresh each fragment when their tabs have been clicked as it auto loads the fragments from start as it uses the view pager. Is there any simplest way out that I could load only a/1 fragment using view pager? Or to reload the fragments? Thanks for your help!
Try to add this to your viewpager:
MY_VIEWPAGER.setOffscreenPageLimit(0);
Check out the documentation.
Pages beyond this limit will be recreated from the adapter when needed.
The limit of 0 will cause a recreation of the fragment when you open a tab.
Hi actually i am using share lock lib and a tab host in my project.
i give a concept of pager in tab so user can swipe tab fragment.
i have a problem. actually in my last fragment i use a map view and a list View. concept is that i show multiple markers on map and will display on list view.
so when user start horizontal scrolling on map view pager will take next or previous fragment (Screen).
how can i manage it. i want that pager work on only list view Not on my map view.
i hope u wil be understand my problem. How can i do this
Thanks in advance.
I have a problem that, I have to implement horizontal swipe view as a paging system and each page shows data from the server, means each page shows dynamic data at run time. I think it is possible with View Pager but in View Pager there is no any fixed layout which is shown on particular page, So, firstly how can we do that, secondly in View Pager all views should be predesigned or preimplemented or we can say that Number of Views we must know. But when we want to take it dynamic when user swipe a page then it goes to next page but progressbar will appear to show the data for corresponding page. So, how can we do this also? Please suggest me any solution regarding the same.
View Pager:
View Pager Demohttp://android-developers.blogspot.in/2011/08/horizontal-view-swiping-with-viewpager.html
Thanks in advance.
Have you tried to implement
viewPager.setOnPageChangeListener(this);
to detect page changement and so loading the page content
The solution isn't in ViewPager but in your custom PagerAdapter. You must subclass the PagerAdapter and add a method to add content to your adapter and call in this method the method notifyDataSetChanged :
public void addPage(Object page) {
// Add page to the arraylist of adapter
notifyDataSetChanged();
}