How to Use TabLayout & Spinner Together for Fast Scrolling Between Fragments - android-spinner

I'm using TabLayout for swiping between many fragments in an activity.
I created a Spinner for fast access between these fragments that user can access each items he wants.
But I don't know how to sync TabLayout info with Spinner items, and how to get each tab's item's number to set it for each spinner items, and how this access works.
I'm using FragmentPagerAdapter and TabLayout works fine.

After 1 week, I found my answer.
I just used viewPager.setCurrentItem(position); in Spinner onItemSelected.
it works for me. when I select one of this items, fragments will change.

Related

Nested scroll view set Disable not working

Respected Android Programmer,
I am facing the one major problem is that nested scroll view not get disable. Here I am using RecylerView inside the Nested ScrollView.
Actually I am using the so many fragments in one Activity so when default recylerview loaded the listing user the Nested Scrolview now i have to click on floating button i have to hide the that fragment with with trance parent layout or frame layout. Its done but now problem is that when i use all function of recycler like
NestedScrollView mScrollView;
mScrollView.setNestedScrollingEnabled(false);
Not working may i know the reason.
Best
Romesh Chand

How to display search results in groups like whatsapp does

I have a viewpager with some tabs. I always use the same fragment with a listview to load some String data into the listview. So far, so good. I now want to implement a searchview. And, I want to group the search results like whatsapp does. So the found listview items should be grouped by the tabs they were found in.
My question is: Which view does whatsapp use and how can I do so ?
Can I keep my simple listview or do I need some other stuff ? I thought about an expandable Listview, could this be a solution ?
Unfortunately, SO doesn't allow me to post an WA screenshot at this moment. But I think you know what I mean.
At the end of this day, I can say that my desired Grouping of Searchresults is definitely possible with an Expandable Listview.
You can hide the Group indicator and disable collapse so it looks like in whatsapp.

Which part of the code should I insert in every activity to show the navigation drawer in every activity

I have an app that already show the navigation drawer in the activity_main.xml ... I do know about using fragments.What I want to do is to show the navigation drawer in every activity without using the fragments...Which part of the codes shoud I copy and paste in every layout to show navigation drawer in every page..Is there any code that I should add to the MainActivity.java or should I add codes to my drawer.xml?
Note: all fragments are put in one layout(drawer.xml)
Which part should I add or modify codes to show navigation drawer in every activity without using fragments?

Nested Recyclerview

How to implement Nested recyclerview in android. I have to implement one recyclerview containing two buttons and inside that recyclerview again in second recyclerview two images have to be there how to implement this can anyone suggest me i am new to android
You cannot place a RecyclerView inside another RecyclerView within a layout xml file. But you can programatically attach a RecyclerView into another one. For example by attaching Layouts programatically. Then you would have two scrollable RecyclerViews. This may sometimes be a thing you don't want to have. For example because of CollapsingToolbarLayouts. Then you can deactivate nested scrolling of the inner RecyclerView by
mRecyclerView.setNestedScrollingEnabled(false);
But if you disable scrolling you will lose the performance advantage of the RecyclerView because the inner one does not recycle anymore if it is not scrollable. But maybe you just need something like this SectionedRecyclerViewAdapter.
Yes we can implement Nested RecyclerView in Android Studio
Just make a Child Adapter and its xml layout and set that adapter inside the Parent Adapter. You can refer to our blog if your have any doubt.
How to Implement Nested RecyclerView in Android

Focus item listview on Android dosent work

I searched lot on internet to find a solution for my problem but I haven't found a answer. I hope someone can help me.
I have a Android application where I made a fragment with 3 tabs. Every tab had a different layout and in every layout there is a listview with different id. The problem is that, when i click on item of listview, only the item of the first tab take focus and background was set to green. In the other tabs the item is selected but focus don't change the background item color.
I had clear the focus on the first tab if was selected but this don't resolve the problem.
this is the code that I implementer on tab
listView.setAdapter(adapter);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View view,
int pos, long arg3) {
view.setSelected(true);
selectedBusiness = businessList.get(pos);
buttonModify.setEnabled(true);
}
});
Any idea?
Thank Max
I found the solution.
The error in my case was made from
ArrayAdapter adapter = new ArrayAdapter(getActivity(), R.layout.my_business_item);
I don't know why but the problem was the layout. In the other two tabs, I used the adapter with another layout android.R.layout.simple_list_item_1. With this layout the focus dosen't work. With my simple layout it works.

Resources