App: defaultNavHost="true"


Agarda backgroundtint uchun bo’lsa shunday bo’ladi.!!!


Download 23.75 Kb.
bet3/4
Sana17.07.2023
Hajmi23.75 Kb.
#1660761
1   2   3   4
Bog'liq
My Lessons

Agarda backgroundtint uchun bo’lsa shunday bo’ladi.!!!
Tab Layout
var tab = ArrayList<String>()

tab.add("Hotels")
tab.add("Eat & Food")
tab.add("Entertainment")
tab.add("Historical")
tab.add("Selfie Time")
tab.add("Masjids")

var adapter = TabAdapter(requireContext(),tab)

vp2.adapter = adapter

vp2.orientation = ViewPager2.ORIENTATION_HORIZONTAL



TabLayoutMediator(tab_layout ,vp2){ tabText ,position ->

when(position){

0 -> tabText.text = "Hotels"

1 -> tabText.text = "Eat & Food"

2 -> tabText.text = "Entertainment"

3 -> tabText.text = "Historical"

4 -> tabText.text = "Selfie Time"

5 -> tabText.text = "Masjids"



}

}.attach()

tab layoutni shunday ishlatsa bo’ladi.Adapter esa RecyclerView bilan bir xil yoziladi.
Navigation.findNavController(view!!).navigate(R.id.action_welcomeScreenFragment_to_selectedFragment)

Navigation shunday ishlatiladi.
View o’rniga this qo’ysa ham bo’ladi agar fragmentda bo’lsa view ham bo’ladi

<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navigation"
app:startDestination="@id/welcomeScreenFragment">

<
fragment
android:id="@+id/welcomeScreenFragment"
android:name="uz.mahbub.newsapp.firstopen.WelcomeScreenFragment"
android:label="@string/hello_blank_fragment"
tools:layout="@layout/fragment_welcome_screen">
<
action
android:id="@+id/action_welcomeScreenFragment_to_selectedFragment"
app:destination="@id/selectedFragment"
app:enterAnim="@anim/alpha"
app:exitAnim="@anim/alpha2"/>
fragment>
<
fragment
android:id="@+id/selectedFragment"
android:name="uz.mahbub.newsapp.firstopen.SelectedFragment"
android:label="fragment_selected"
tools:layout="@layout/fragment_selected" />

navigation>


Animatsia shunday beriladi
<action
android:id="@+id/action_welcomeScreenFragment_to_selectedFragment"
app:destination="@id/selectedFragment"
app:enterAnim="@anim/alpha"
app:exitAnim="@anim/alpha2"/>


Download 23.75 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling