scrollToPosition doesn't work with recyclerview of multiple view types - android-fragments

i have 3 recyclerviews located at 3 tabs of tablayout. tab 1 and 2 have a recyclerview of one type of view and scrollToPosition method works fine with them but with tab 3 recyclerview the method works and the code is executed but there is no action and no scrolling.
is there a way that you guys can provide to overcome this dilemma!!
thanks in advance.

Related

NavigationController and View Hierarchy issue

I have 1 (rootViewController) view controller which is embedded in navigation controller. Then i pushed another view controller (secondViewController), which has search controller in title view. When i am trying search become first responder (Active) i got this in terminal:
Warning: Attempt to present
"AppName.CustomSearchViewController: 0x7face0c20eb0> on
whose view is
not in the window hierarchy!
This happens only in iOS lower than 11. When i embed this second view controller in navigation controller and present it modally all works good, but i need exactly pushing. How can i solve this?
I solved it! I need to make definesPresentationContext false in rootViewController to make it work on another one!

How create and delete dynamically tabbed page

I am working on Xamarin.forms chat app, How to achieve this task.
Attached screenshot 3 group available and after click respected chat is activated and bind, this group bind dynamically. Its would be 20 or more than 20.
https://code.msdn.microsoft.com/windowsapps/XamarinForms-MVVM-Custom-dfc146ee
In this article we can create our own tabs so, we can add or delete the items dynamically need to change RibbonOptions ItemsSource.
Hope this is useful for you.

Espresso perform click on button located in fragment

I've got the following problem. I want to test my application with Espresso. Therefore I want to click a button which is part of the "Buttons" fragment, this fragment is located in a frame-layout in the MainActivity.
Ofcourse I can check if the frame-layout is displayed but I can not reach the layout of the fragment which is located into the frame-layout.
So my question is, how can I reach the layout of the fragment into the frame-layout, so I can click on a button into the fragment.
The result at the moment is a NoViewMatchException:
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id:...
Thanks in advance!
Edit: The exception shows the view hierarchy
These are the methods I'm calling:
onView(ViewMatchers.withId(R.id.buttons)).check(matches(isDisplayed()));
This is the frame-layout in the MainActivity for the buttons fragment:
onView(withText("LOCATIONS")).perform(click());
The locations buttons is in the Buttons fragment
withId on the button id in stead of withText doesn't make sense.
The question is not very clear. It does not matter which layout you are using. Espresso can locate the element on the view hierarchy. If your case, you're getting NoViewMatchException. That means the view (R.id.buttons) is not there when you're checking.
For debugging, you can add some wait (SystemClock.sleep(2000)) and check if it works.
If that works, you need to write the idling resource to wait for the buttons fragment to appear.

Android - NestedFragments participate in populating the options menu

i am implementing the new nested fragment feature and had stumble into a problem.
my view is basically this:
a main activity(A) that includes a fragment(B), this fragment(B) includes a pager adapter that has 3 pages each of them is a fragment(C) also.
previously to the new getchildfragmentmanger this was not doable, but it works perfectly.
but one issue did arise, i want fragments C to be able to participate in populating the option menu.
i tired putting setHasOptionsMenu(true) in the onActivityCreated method on each of my C fragments and overriding also onCreateOptionsMenu but nothing happens...
if i try to populate the menu from fragment B (which is the container of the pager adapter) i can change the menu items...
any thoughts ?
Thanks.
Yes they can.
With android 4.2 or support library revisiion 11 nested fragments participate in populating options menu, as allways you need to call setHasOptionsMenu(true) during onCreate().
But if you are using ActionBarSherlock they won't, you have to manually call from parent fragment onCreateOptionsMenu() nested fragment method onCreateOptionsMenu().
Update: issue
From my read of the source code, it appears that the implementations of FragmentManager and Activity only work with the root FragmentManager for adding to the options menu/action bar, not and child FragmentManager instances.
Fragment B presumably will need to manage the options menu/action bar on behalf of the contents of the ViewPager, changing what is in the options menu/action bar based upon the pages being shown and hidden in the pager.

replace fragments inside fragment displayed by the viewpager

Please see the wireframe image http://i.imgur.com/dPAMA.png first.
I am using a ViewPager to display fragments inside a FragmentActivity. ViewPager gets fragments from the attached FragmentPagerAdapter
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mAdapter = new HomePagerAdapter(getSupportFragmentManager());
mViewPager.setAdapter(mAdapter);
Suppose viewpager has 3 fragments to display say Fragment1, Fragment2, Fragment3.
In the above image 'displaying fragment1' is the title for the first fragment, "Fragment1". This fragment is a list fragment and displays a list. Fragment2 and Fragment3 have their own content to display. when the user swipes on the screen, ViewPager will display the next fragment, "Fragment2".
What i want is that, when an item from the list(displayed by Fragment1) is clicked, Fragment1 should be completely replaced with some other Fragment, say Fragment4 (this is different fragment and is not returned by the attached adapter). when Fragment4 is displayed, the actionbar should change its content. whenever user works on Fragment4 and onBackPress or an action from the ActionBar, Fragment1 with the list should be displayed again. Meanwhile ViewPager should behave the same i.e on swipe, and the next fragment(in our case Fragment2) will be displayed.
basically, i want to get the same behavior as in example at :
http://developer.android.com/training/basics/fragments/fragment-ui.html#Replace
In this example the ListFragment is displayed directly inside a FragmentActivity. I am displaying the ListFragment with a ViewPager. I want the same functionality from the above example but inside fragments displayed with ViewPager. This was very difficult to achieve before the release of Android 4.2. this version of android supports nested fragments using getChildFragmentManager() so, i see some hope.
I am trying this on my side for many days and also scanned entire stackoverflow for Q & A related to nested fragments but didn't get what i want.
So, is this possible to achieve? if yes, then how to?
This was a big problem before Android 4.2 but it seems to easier now with nested fragments, apart from ensuring the back button works. I posted my solution to your question over here: https://stackoverflow.com/a/13925130/467509
My solution answers everything you asked apart from changing the ActionBar.

Resources