Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – Hide or close BottomSheetDialog on item menu click (Kotlin)

Posted on November 14, 2022

Solution 1 :

To close the bottomSheet Dialog after an Item Click , try the following

 navDrawer.setNavigationItemSelectedListener { menuItem ->
            when (menuItem!!.itemId) {
                R.id.ndListFolder -> this.startActivity(Intent(activity, 
                ndActFolder::class.java))
                 dismiss() // add this whenever you want to close the bottomSheet

            }
            true
        }

So you simply need to add this method dismiss()

Problem :

Im currently working on an app, which has a BottomSheetDialog as navigation menu. This menu, is called by the Toolbar Navigation Item.

When calling the BottomSheetDialog, it shows up, and clicking on an item of the list creates the related activity, which is expected. However, when i close the newly opened activity the BottomSheetDialog shows up again, which is not the intended behaviour.

What it does

Are there any ways to prevent the BottomSheetFragment to show up?

I tried using .also after the creation of the Intent, but there are no function dedicated to hide or close the Dialog

Here is the BottomSheetFragment code:

class frgBottomSheetDrawer : BottomSheetDialogFragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        super.onCreateView(inflater, container, savedInstanceState)
        return inflater.inflate(R.layout.fragment_bottomsheet, container, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)

        navDrawer.setNavigationItemSelectedListener { menuItem ->
            when (menuItem!!.itemId) {
                R.id.ndListFolder -> this.startActivity(Intent(activity, ndActFolder::class.java))
                R.id.ndListSettings -> this.startActivity(Intent(activity, ndActSettings::class.java))
                R.id.ndListAbout -> this.startActivity(Intent(activity, actAbout::class.java))
            }
            true
        }
    }
}

READ  [ANSWERED] Android Studio - Naming Issues
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress