SmoothBottomBar котлин ⇐ Android
-
Anonymous
SmoothBottomBar котлин
https://github.com/ibrahimsn98/SmoothBottomBar I am making the smoothBottomBar shared by a friend in Java, but when I want to make it in Kotlin, I get an error in the mainactivity codes. Example 1: Type in the object section, Example 2: Boolean Can anyone share appropriate MainActivity codes for Kotlin? My code
package com.paranoyaq.iconoynatilantabvenav import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.appcompat.widget.Toolbar import me.ibrahimsn.lib.OnItemSelectedListener import me.ibrahimsn.lib.SmoothBottomBar class MainActivity : AppCompatActivity() { private lateinit var smoothBottomBar: SmoothBottomBar private lateinit var toolbar: Toolbar override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) smoothBottomBar = findViewById(R.id.bottombar) toolbar = findViewById(R.id.toolbar) smoothBottomBar.setOnItemSelectedListener { pos -> when (pos) { 0 -> { val fragmentManager = supportFragmentManager val fragmentTransaction = fragmentManager.beginTransaction() fragmentTransaction.replace(R.id.framelayout, HomeFragment()) fragmentTransaction.commit() true } 1 -> { val fragmentManager = supportFragmentManager val fragmentTransaction = fragmentManager.beginTransaction() fragmentTransaction.replace(R.id.framelayout, SettingFragment()) fragmentTransaction.commit() true } 2 -> { val fragmentManager = supportFragmentManager val fragmentTransaction = fragmentManager.beginTransaction() fragmentTransaction.replace(R.id.framelayout, PersonFragment()) fragmentTransaction.commit() true } 3 -> { val fragmentManager = supportFragmentManager val fragmentTransaction = fragmentManager.beginTransaction() fragmentTransaction.replace(R.id.framelayout, MoreFragment()) fragmentTransaction.commit() true } } false } } }
Источник: https://stackoverflow.com/questions/780 ... bar-kotlin
https://github.com/ibrahimsn98/SmoothBottomBar I am making the smoothBottomBar shared by a friend in Java, but when I want to make it in Kotlin, I get an error in the mainactivity codes. Example 1: Type in the object section, Example 2: Boolean Can anyone share appropriate MainActivity codes for Kotlin? My code
package com.paranoyaq.iconoynatilantabvenav import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.appcompat.widget.Toolbar import me.ibrahimsn.lib.OnItemSelectedListener import me.ibrahimsn.lib.SmoothBottomBar class MainActivity : AppCompatActivity() { private lateinit var smoothBottomBar: SmoothBottomBar private lateinit var toolbar: Toolbar override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) smoothBottomBar = findViewById(R.id.bottombar) toolbar = findViewById(R.id.toolbar) smoothBottomBar.setOnItemSelectedListener { pos -> when (pos) { 0 -> { val fragmentManager = supportFragmentManager val fragmentTransaction = fragmentManager.beginTransaction() fragmentTransaction.replace(R.id.framelayout, HomeFragment()) fragmentTransaction.commit() true } 1 -> { val fragmentManager = supportFragmentManager val fragmentTransaction = fragmentManager.beginTransaction() fragmentTransaction.replace(R.id.framelayout, SettingFragment()) fragmentTransaction.commit() true } 2 -> { val fragmentManager = supportFragmentManager val fragmentTransaction = fragmentManager.beginTransaction() fragmentTransaction.replace(R.id.framelayout, PersonFragment()) fragmentTransaction.commit() true } 3 -> { val fragmentManager = supportFragmentManager val fragmentTransaction = fragmentManager.beginTransaction() fragmentTransaction.replace(R.id.framelayout, MoreFragment()) fragmentTransaction.commit() true } } false } } }
Источник: https://stackoverflow.com/questions/780 ... bar-kotlin
Мобильная версия