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.
Related
I am trying to create a main page in my android app in which there are multiple things a user can select to do. For this page, I am thinking of using a RecyclerView with a LinearLayoutManager. For each of the views in the RecyclerView (none of which are as big as the screen), I want a user to be able to swipe into a Fragment (which is as big as the screen).
I have already tried using multiple ViewPagers to solve this problem. When keeping the ViewPager as big as the screen (the default), the Fragment would be the correct size, except the view in the RecyclerView would be as big as the screen (I want it to only wrap_content). When shrinking the size of the ViewPager, the Fragment would not be as big as the screen, but the View in the RecyclerView would be the correct size.
I have heard that one can listen for a user's swipe on a view, except:
- I don't know if that is what I should do in my case, and
- I don't know how to do it for my situation
If listening for a user's swipe is the correct way to go, please give some direction and/or code on how to complete what I want to do. If it is not the way to go, please provide an alternate way.
Thanks in advance!
Update: Here is a picture describing what I mean:
// define your fragment with recycle view
class FragmentA extends Fragment {
// with recycler view
// in click on recycler item method as i posted
// 1) do check if pager fragment exist in pager adapter
// 2) if not create one
// 3) and move to it using pager method
}
// define second without
class FragmentB extends Fragment {
// without
}
// create pager
ViewPager vp = new ViewPager(Context);
// create list with fragments for pager adapter
// when you will swipe you will move from A to B
List<Fragment> // add FragmentA + FragmentB
// https://developer.android.com/reference/android/support/v4/view/PagerAdapter.html
// create pager adapter - implement own or user FragmentPagerAdapter
PagerAdapter ... = new MyPagerAdapter(List<Fragment>);
// set view pager with adapter
viewPager.setAdapter(PagerAdapter);
// add view pager to activity view - or some content view
I already tried this on my own; the viewpager would not allow for the
correct sizes. Either the full-screen fragment size was shrunk down to
the size of the View in the recyclerview, or the view in the
recyclerview was full-screen. – Flare Cat
its working:
Oh wait, read the code wrong. But still, I need to base FragmentB off
of what was swiped in FragmentA – Flare Cat
solution:
when you click on recycler item dynamic create new fragmentB and call move to fragmentB on pager (before create new one do a check if fragment not exist already!)
or if you don't use any click on item method but just constant recycler item content create such fragments corresponding to each entry in recycler
or create some sort of map which will map each entry in recycler to to its corresponding fragment content
As I understand it, I would need to create an onClickListener for each
view in the RecyclerView. But, would that onClickListener be called
when a user swipes the corresponding view? – Flare Cat
Actually, this might work with an onTouchListener. I'll have to try it out. – Flare Cat
once again:
it depends what u want to achieve - if recycler is a way of brief for each fragments and you know the content and want to present each entry for recycler item counting from top to bottom then you need add those fragments one by one in same order from left to right
#FlareCat but why using pager here ? not better to open new activity or add fragment with transition on recycler item click ?
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.
I have a ListFragment and at the footer of the list fragment I added another fragment that contains google map. I added swipe gestures left->right, right->left to whole Activity and that works fine. The problem is that when user swipes on top of the map it calls left->right, right-left functions. I want to disable these functions for my map view (fragment), and when swipe occurs on map view (fragment) do only map related movements.
If anyone knows how to implement it I would greatly appreciate it.
Based on FragmentPagerAdapter, I have inflated my view pager and I can see my items in each page. How to know, which page is clicked by user to direct him/her see detail of information?
Thanks
As far as I know, there is no way to get the current displayed Fragment by the FragmentPagerAdapter, so what I can suggest is keep an position member variable for each Fragment that is added in the pager so you can use that to know which fragment is clicked.
Is there some way to show a small portion of the adjacent fragments while using the ViewPager in Android compatibility package.
The view that I want to make will show the current fragment in center and the edges of the fragments which are before and after the current one on either side.
I believe a ViewPager indicator would be the best solution available. Showing that there are pages to either side.
http://androidforums.com/application-announcements/391561-android-viewpager-indicator.html