android-jetpack

Are Android system widgets within app configurable?

别说谁变了你拦得住时间么 提交于 2021-01-22 04:59:34
问题 When I press one of the volume hardware buttons, Android's system is shown a depicted. Naturally this also happens when I press whithin my app. Is it possible to configure the style of these Android system stuff like volume? Or at least when I open these system stuff in my app? EDIT: As recommended in the comments, I've overwritten onKeyDown , but the adjustStreamVolume switches between 0 and 1 only. override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { when (event?.keyCode) {

How to use android navigation without binding to UI in ViewModel (MVVM)?

≯℡__Kan透↙ 提交于 2021-01-20 19:31:57
问题 I am using android navigation that was presented at Google I/O 2018 and it seems like I can use it by binding to some view or by using NavHost to get it from Fragment. But what I need is to navigate to another specific view from ViewModel from my first fragment depending on several conditions. For ViewModel , I extend AndroidViewModel , but I cannot understand how to do next. I cannot cast getApplication to Fragment/Activity and I can't use NavHostFragment . Also I cannot just bind navigation

ViewPager2 crash

断了今生、忘了曾经 提交于 2021-01-03 05:59:39
问题 i am using Advance Navigation Component with BottomNavigationView, In One tab i have viewPager2 first clicked on tab is working fine but second time come on that tab application keep crashing. Below is crashlog if anyone can help thanks. java.lang.IllegalArgumentException at androidx.core.util.Preconditions.checkArgument(Preconditions.java:36) at androidx.viewpager2.adapter.FragmentStateAdapter.onAttachedToRecyclerView(FragmentStateAdapter.java:140) at androidx.recyclerview.widget

ViewPager2 crash

独自空忆成欢 提交于 2021-01-03 05:58:34
问题 i am using Advance Navigation Component with BottomNavigationView, In One tab i have viewPager2 first clicked on tab is working fine but second time come on that tab application keep crashing. Below is crashlog if anyone can help thanks. java.lang.IllegalArgumentException at androidx.core.util.Preconditions.checkArgument(Preconditions.java:36) at androidx.viewpager2.adapter.FragmentStateAdapter.onAttachedToRecyclerView(FragmentStateAdapter.java:140) at androidx.recyclerview.widget

ViewPager2 crash

删除回忆录丶 提交于 2021-01-03 05:58:00
问题 i am using Advance Navigation Component with BottomNavigationView, In One tab i have viewPager2 first clicked on tab is working fine but second time come on that tab application keep crashing. Below is crashlog if anyone can help thanks. java.lang.IllegalArgumentException at androidx.core.util.Preconditions.checkArgument(Preconditions.java:36) at androidx.viewpager2.adapter.FragmentStateAdapter.onAttachedToRecyclerView(FragmentStateAdapter.java:140) at androidx.recyclerview.widget

Android Room Database Ignore Problem “Tried the following constructors but they failed to match”

情到浓时终转凉″ 提交于 2020-12-11 05:10:12
问题 My entity class: @Entity(tableName = "student") data class Student( var name: String, var age: Int, var gpa: Double, var isSingle: Boolean, @PrimaryKey(autoGenerate = true) var id: Long = 0, @Ignore //don't create column in database, just for run time use var isSelected: Boolean = false ) And then I insert like this (tested in androidTest ): val student = Student("Sam", 27, 3.5, true) studentDao.insert(student) It gives me this error right after I added the @Ignore annotation: C:\Android

Android Room Database Ignore Problem “Tried the following constructors but they failed to match”

早过忘川 提交于 2020-12-11 05:08:31
问题 My entity class: @Entity(tableName = "student") data class Student( var name: String, var age: Int, var gpa: Double, var isSingle: Boolean, @PrimaryKey(autoGenerate = true) var id: Long = 0, @Ignore //don't create column in database, just for run time use var isSelected: Boolean = false ) And then I insert like this (tested in androidTest ): val student = Student("Sam", 27, 3.5, true) studentDao.insert(student) It gives me this error right after I added the @Ignore annotation: C:\Android

Android Room Database Ignore Problem “Tried the following constructors but they failed to match”

烈酒焚心 提交于 2020-12-11 05:08:00
问题 My entity class: @Entity(tableName = "student") data class Student( var name: String, var age: Int, var gpa: Double, var isSingle: Boolean, @PrimaryKey(autoGenerate = true) var id: Long = 0, @Ignore //don't create column in database, just for run time use var isSelected: Boolean = false ) And then I insert like this (tested in androidTest ): val student = Student("Sam", 27, 3.5, true) studentDao.insert(student) It gives me this error right after I added the @Ignore annotation: C:\Android

Type 'State<List<User>?>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate

我的未来我决定 提交于 2020-12-08 07:27:55
问题 I'm trying to get a value from LiveData with observeAsState in jetpack compose, but I get a weird error Type 'State<List?>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate Code @Composable fun UserScreen(userViewModel:UserViewModel){ val items: List<User> by userViewModel.fetchUserList.observeAsState() UserList(userList = items) } ViewModel class UserViewModel: ViewModel() { private val dataSource = UserDataSource() val fetchUserList = liveData { emit

Navigation Architecture component- How to refresh a fragment?

南笙酒味 提交于 2020-12-08 05:58:31
问题 I have a ListFragment that has a recyclerview and onClick on any items opens the DetailsFragment. The details fragment contains another recyclerview on the bottom that shows "MORE ITEMS". Now onClick on any of these items should open the DetailsFragment for that particular item. Basically the fragment needs to be refreshed. In the past, I would just replace fragment using fragmentManager. How do I go about refreshing the fragment? How can I create an action that points to the same fragment?