我正在尝试使用示例项目 android-sunflower 对视图模型进行数据绑定。当前的问题是,当我尝试构建项目时,我error: cannot find symbol symbol: class FragmentShopBindingImpl
location: package {{packageName}}.databinding在类中遇到错误,DataBindinMapperImpl
我不确定我在这里缺少什么,因为我添加了示例项目中的所有内容。该类FragmentShopBindingImpl没有生成,或者不应该生成?由于我在 android 向日葵示例中看不到任何以“Impl”结尾的类的出现
我的代码:
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val factory = InjectorUtils.provideShopViewModelFactory(context!!)
val shopViewModel = ViewModelProviders.of(this, factory)
.get(ShopViewModel::class.java)
val binding = DataBindingUtil.inflate<FragmentShopBinding>(
inflater, R.layout.fragment_shop, container, false).apply {
viewModel = shopViewModel
lifecycleOwner = this@ShopFragment
}
return binding.root
}
Run Code Online (Sandbox Code Playgroud)
布局:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="{{packageName}}.viewmodel.ShopViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".fragments.ShopFragment"> …Run Code Online (Sandbox Code Playgroud) data-binding android kotlin android-databinding android-jetpack
我使用创建元素,var l = document.createElement("label");并使用分配其属性l.setAttribute("formControlName","e");。问题在于setAttribute方法将formControlName转换为小写字母,如下图所示。我与ionic一起工作,因此需要使用大写字母。有人看到我做错了吗?
我试图更改通过调用 getElementsByClassName 方法收到的所有元素的样式。问题是,它在之前编译过时确实可以工作(我注释掉这些行以使其编译),它只是说 cmd 中的错误。编译后,我只是将线路恢复正常,它们不断给出错误,但在浏览器中正常工作。对这种奇怪的行为有什么想法吗?
注释掉时:
当没有评论并给出错误时:
angular5 ×2
html ×2
javascript ×2
typescript ×2
android ×1
angular ×1
angular6 ×1
css ×1
data-binding ×1
dom ×1
forms ×1
kotlin ×1
npm ×1
xml2js ×1