在android中,每个fragment都覆盖了onCreateOptionsMenu,这提供了在每个fragment中添加单独的选项菜单的可能性。当应用程序栏对于应用程序是通用的时,如何在从抽屉中更改页面时使用 flutter 来实现这一点
我正在使用带有 FragmentStateAdapter 的 ViewPager2,我正在调用 notifyItemChanged(position)。但正如预期的那样 createFragment 方法不会再次调用。这是预期的行为还是错误,我该怎么办
我的代码是
class EEditionPagerAdapter(
fragmentManager: FragmentManager, lifecycle: Lifecycle, private var date: String
) : FragmentStateAdapter(fragmentManager, lifecycle) {
private var menuList = emptyList<EEditionMenu>()
override fun getItemCount(): Int = menuList.size
override fun createFragment(position: Int): Fragment {
val menu = menuList[position]
return EEditionListingFragment.newInstance(menu, date)
}
fun submitList(list: List<EEditionMenu>) {
menuList = list
notifyItemRangeChanged(0, menuList.size)
}
fun changeDate(date: String, position: Int){
this.date = date
notifyItemChanged(position)
}
}
Run Code Online (Sandbox Code Playgroud) 我通过androidX库在kotlin中使用会议室数据库。当我下载feed并尝试保存在数据库中时,崩溃发生,显示错误sqlite:NOTNULL约束失败.Json Feed在某些标签中包含对象,并且在某些标签中也包含空数据。
但是我没有在数据库中添加任何不为null的属性。在另一个项目中,iam使用java中的arch库中的room数据库以相同的feed实际工作。
我尝试了一些seconday构造函数
constructor(0, "", "", "", "", listOf<SubMenuApi>, 0)
Run Code Online (Sandbox Code Playgroud)
还有这个
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
@Entity(tableName = "tableMenu")
data class MenuApi(
@PrimaryKey(autoGenerate = true) var id: Int = 0,
@ColumnInfo(name = "title") @SerializedName("Title") var title: String = "",
@ColumnInfo(name = "TITLE_OF_ACCESS") @SerializedName("TitleofAccess") var titleOfAccess: String = "",
@ColumnInfo(name = "apexFileName") @SerializedName("AspxFileName") var apexFileName: String = "",
@ColumnInfo(name = "sectionId") @SerializedName("SectionId") var sectionId: String = "",
@TypeConverters(MenuConvertors::class) @SerializedName("SubMenu") var subMenuApi: List<SubMenuApi> = listOf<SubMenuApi>(),
@ColumnInfo(name = "subSecCount") …Run Code Online (Sandbox Code Playgroud) 我正在使用android库androidx.appcompat:appcompat:1.0.2。在一个代码实验室工作管理器上工作。我需要从ViewModel获取实时数据,而我正在使用它
mViewModel!!.getOutputWorkInfo()?.observe(this, Observer<List<WorkInfo>> {
})
Run Code Online (Sandbox Code Playgroud)
但是此变量显示错误- 类型不匹配。必需:生命周期所有者。找到:模糊活动
我用谷歌搜索表示不需要扩展生命周期所有者,默认情况下,appcompact活动会实现生命周期所有者。
我也在另一个项目中进行了此工作,但未发现任何问题。我不知道为什么我在这个项目中遇到这个错误。
`
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.RadioGroup
import com.bumptech.glide.Glide
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.work.WorkInfo
class BlurActivity : AppCompatActivity() {
private var mViewModel: BlurViewModel? = null
private var mImageView: ImageView? = null
private var mProgressBar: ProgressBar? = null
private var mGoButton: Button? = null
private var mOutputButton: Button? = null
private var mCancelButton: Button? = null
/**
* Get the blur …Run Code Online (Sandbox Code Playgroud) android kotlin-android-extensions android-architecture-components androidx
android ×4
androidx ×2
android-architecture-components ×1
android-room ×1
flutter ×1
kotlin ×1