Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/src/main/java/com/example/app/EmptyScreenFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.app

import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment

class EmptyScreenFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
return TextView(requireContext()).apply {
text = context.getString(R.string.no_bottom_navigation_defined)
gravity = Gravity.CENTER
textSize = 16f
setPadding(16, 16, 16, 16)
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)
}
}
}
7 changes: 7 additions & 0 deletions app/src/main/java/com/example/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ class MainActivity : AppCompatActivity() {
}
}

private fun showEmptyScreen() {
val transaction = supportFragmentManager.beginTransaction()
val fragment = EmptyScreenFragment()
transaction.replace(R.id.fragment_container, fragment, "empty_screen")
transaction.commitNowAllowingStateLoss()
}

private fun setupBottomNavigation() {
val sortedTabs = bottomNavEntries.sortedBy { it.bottomNavPosition() }
binding.bottomNav.menu.clear()
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">Your App Name</string>
<string name="no_bottom_navigation_defined">No bottom navigation defined</string>
</resources>