need onbackpressed function in MeowBottomNavigation library - java

https://github.com/oneHamidreza/MeowBottomNavigation
i have implemented bottom navigation bar using above library but when i press back button it is directly closing the app even when i am in another fragment alsp.
please guide me that when i press back button it should come to home fragment and when i am in another fragment the back button should work accordingly to that respective fragment.
when i press back button in bottom navigation bar it should come to home fragment if it is in another fragment other than home if it is in home fragment then it can close app.

Related

1 Button 2 activity in android studio using java

How do I open another activity with the same button I clicked earlier? For example, I click button A and goes to Activity 1 and I click home and click button A again and must go to Activity 2.
I tried putting id on button in xml and call different activity on its java.
Imagine if the button is from HomeActivity,let the launcher activity pass an ExtraKey to the HomeActivity and again another ExtraKey at the OnBackPressed of the Activity you are navigating to after clicking the button.Set the onClickListner according to the String passed by those activities.

Fragment showing nothing when starting my app for first time

I have an app with bottom navigation fragment activity
I have placed text views and buttons on my home fragment.
further these fragments are placed in a frame layout.
when I launch my app my home fragment shows nothing just blank screen it loads everything when I
switch between fragments.
I want to fix this, so that when I launch my app everything that is on my home fragment shows up.
because you didn't specify the first fragment to show,
in the onCreate you have to do this :
first checked the bottomNavigation item, that you want to start with :
bottomNavigation.getMenu().findItem(R.id.item).setChecked(true);
then put the first fragment in frame layout

How do I save the state of fragments in android?

I'm using a bottom navigation view which has 2 menu items. Each menu item upon clicking loads a fragment onto the MainActivity.
The first fragment is the home fragment where a RecyclerView shows a list of items and the second fragment contains a simple form.
now whenever I switch back and forth between these fragments, their previous states are lost and the fragment is recreated. This is a big issue for me because suppose I scroll to, let's say the 15th item of the list present in the home fragment. After scrolling, I navigate to the second fragment and then I navigate back. What happens is that the home fragment gets recreated and to see the 15th item I have to scroll again.
What should I do to handle this?

Add Google Map to a button of bottom navigation bar

I try to put the bottom navigation bar under Google Map and I can't. When I tap the second button of navigation bar I want to open google map fragment but the bar stays at the bottom. Does anyone know how it can be done?
Here is an example of exactly what I want:
My app uses a bottom navigation layout and loads up three fragments (on one of them is a google map fragment), hence the bottom navigation menu stays there for all the three fragment of the app!
If you want to have a screen where the bottom navigation isn't present, why not use an activity with a layout without a bottom navigation view for that screen ? The user will just navigate back to the previous activity when the job is done.

tabbed activity fragments swipe unlock if button is clicked

I made a tabbed activity with two fragments and i want the activity to be locked at fragment1 unless the user click a button in fragment1 then the activity switch to fragment2 automatically and the swipe is unlocked so you can switch between fragment1 and fragment2. I have been learning java for a week now and creating this tow fragment takes me a lot of effort and headache and since i have not studied java or other programming languages i think i can't figure this one on my own please help me.
That's very simple. If you want to work it with a button, add button inside the tab, and at Onclick View call the 2nd fragment method.

Categories

Resources