Comments (7)
Good morning, @rajam1215 👋
Thank you for provided information, I really appreciate it. However, as I wrote below - it's not a default behavior for alternative native android widget. Moreover, it looks like as an application layer responsibility to cache fragments. I can recommend you to look at fragmentFactory - probably, it will cover you case.
Best wishes,
Alex
from expandablebottombar.
Hi @rajam1215,
sorry for a bit late replay. Did you check the default BottomBarNavigation view? Does it behave in an expected way? Also, did I understand you correctly - double-clicking on the same item causes Fragment recreation? If you don't mind, it would be really cool, if you can record a small video, which reflects wrong behaviour.
Looking forward to hearing from you
from expandablebottombar.
Hi @rajam1215,
sorry for a bit late replay. Did you check the default BottomBarNavigation view? Does it behave in an expected way? Also, did I understand you correctly - double-clicking on the same item causes Fragment recreation? If you don't mind, it would be really cool, if you can record a small video, which reflects wrong behaviour.
Looking forward to hearing from you
Hello @st235
I am very glade to see you again, i know the default behavior of bottom navigation, this is used only for show activities or fragments, but in this library we move forward already, it have MVVM support, but default doesn't, we need to avoid the recreation of fragment, now please check what is happen right now.
your qus - double-clicking on the same item causes Fragment recreation?
no it's not, it recreate fragment again when click on other menu item,
it will recreate again and again, i want when all fragments create once, then no need to create again, just visible and gone.
i make one little video,it will clear your query
Please check once.
from expandablebottombar.
Hi @rajam1215,
sorry, it was a really crazy week. I'll be able to take a look at the problem only at the end of this week.
PS: However, it's always welcomed any kind of contribution here. So, if you have any ideas on how to solve this problem, do not hesitate, please, to create a pull request.
Kind regards,
Alexander Dadukin
from expandablebottombar.
Hello @st235
not an issue, please see on the issue end of the week, but i have one solution for that.
public class MainActivity extends AppCompatActivity {
final Fragment fragment1 = new HomeFragment();
final Fragment fragment2 = new DashboardFragment();
final Fragment fragment3 = new NotificationsFragment();
final FragmentManager fm = getSupportFragmentManager();
Fragment active = fragment1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
fm.beginTransaction().add(R.id.main_container, fragment3, "3").hide(fragment3).commit();
fm.beginTransaction().add(R.id.main_container, fragment2, "2").hide(fragment2).commit();
fm.beginTransaction().add(R.id.main_container,fragment1, "1").commit();
}
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
fm.beginTransaction().hide(active).show(fragment1).commit();
active = fragment1;
return true;
case R.id.navigation_dashboard:
fm.beginTransaction().hide(active).show(fragment2).commit();
active = fragment2;
return true;
case R.id.navigation_notifications:
fm.beginTransaction().hide(active).show(fragment3).commit();
active = fragment3;
return true;
}
return false;
}
};`
}
But this solution work with onItemselectedLinstner of bottom navigation.
but not with MVVM Technique
Refer to this for the official solution.
https://github.com/android/architecture-components-samples/tree/master/NavigationAdvancedSample
Please check the official solution for MVVM support, the solution code work with kotlin, and expandable bottom bar project work with kotlin, so you can handle this
Please look in to it.
Regards
Bishal Malick
from expandablebottombar.
@rajam1215, hi 👋
Hopefully, you are well. I took a look at the problem. I tried to reproduce similar behaviour with default android components, so I've changed ExpandableBottomBar
to
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:backgroundTint="#fff"
app:menu="@menu/navigation_menu"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
and also used NavigationUI (an alternative for native android view).
NavigationUI.setupWithNavController(bottomNavigation, navigationController)
Unfortunately, the behaviour you mentioned below is not followed by material design components. As it's not a native behaviour, I cannot implement it in this library. The users will not expect such behaviour at this component.
I've made a small video of BottomNavigationView
. This video contains the default behaviour for default android widget:
PS: also, I looked at the provided sample. The main highlight here: they don't use NavigationUI
, but do use a custom extension (BottomNavigationView#setupWithNavController
) to provide required behaviour.
Kind regards,
Alexander Dadukin
from expandablebottombar.
@st235 hello
I understand what you want to say, it is not necessary to add this functionality in the library, but in my suggestion this feature you can see in maximum apps, you can check from your side also, those who use bottom navigation in the app. coz some time user don't want to see the app screen again and again from start, user always want to use it from where he/she left (App User), i hope you can understand,
you can add this functionality in your lib, if user want to use this functionality in app they can use, if not they can not use (Coder)
Thanks and Regards
Bishal Malick
from expandablebottombar.
Related Issues (20)
- Is there a way to use this in a java project? HOT 32
- bottom bar has a peek height HOT 27
- How add badge for menu items? HOT 5
- custom font support for text in bottom bar HOT 4
- ExpandableBottomBarNavigationUI navigation not working when onItemSelectedListener added HOT 9
- Hacktoberfest 2020 HOT 1
- how can i use onItemSelectedListener?
- dynamic item control HOT 3
- Default Item selection HOT 3
- setting Font or typeface to title's HOT 1
- There was a problem when importing version 1.4.0 HOT 3
- Back Stack maintain Without Recreating Fragment HOT 6
- Back Stack maintain Without Recreating Fragment HOT 1
- Bottom Bar not showing properly HOT 4
- ExpandableBottomBarScrollableBehavior isn't working for me. HOT 9
- Failed to resolve: HOT 1
- how to select menu item via position HOT 1
- Class referenced in the layout file, github.com.st235.lib_expandablebottombar.ExpandableBottomBar, was not found in the project or the libraries HOT 6
- White background under icon and title of item selected in a fragment layout HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expandablebottombar.