Похожие чаты

I am using Navigation Bar + Fragments in my app.

It is taking a lot of time in switching the fragments.
I am using this code ->
navigationView.setNavigationItemSelectedListener(
item -> {
item.setChecked(true);
drawerLayout.closeDrawers();
switch (item.getItemId()){
case R.id.places :
PlacesFragment fragment1 = new PlacesFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.main_content, fragment1);
transaction.addToBackStack(null);
transaction.commit();
break;
case R.id.restaurants :
RestaurantsFragment fragment2 = new RestaurantsFragment();
FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction();
transaction1.replace(R.id.main_content, fragment2);
transaction1.addToBackStack(null);
transaction1.commit();
break;
case R.id.about :
AboutFragment fragment3 = new AboutFragment();
FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
transaction2.replace(R.id.main_content, fragment3);
transaction2.addToBackStack(null);
transaction2.commit();
break;
case R.id.hotels :
HotelsFragment fragment4 = new HotelsFragment();
FragmentTransaction transaction3 = getSupportFragmentManager().beginTransaction();
transaction3.replace(R.id.main_content, fragment4);
transaction3.addToBackStack(null);
transaction3.commit();
}

return true;
}
);
Is there any faster way to do that ?

3 ответов

15 просмотров

It looks like you posted long piece of code, consider editing it out and putting it on hastebin.com and pasting link to it instead. Alternatively, send your code in a file.

How much time does it take?

Is there need to define 3 different transactions?? You could define only one transaction outside switch... And call it inside different cases

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта