我想使用自定义视图来试用 ViewBinding,例如:
MainActivity <=> layout_main.xml
MyCustomView <=> layout_my_custom_view.xml
Run Code Online (Sandbox Code Playgroud)
布局_main.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.example.myapplication.MyCustomView
android:id="@+id/custom_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
layout_my_custom_view.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Line1" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#2389bb" />
<TextView
android:id="@+id/line2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Line2" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
主要活动
class MainActivity : AppCompatActivity() {
private lateinit var binding: LayoutMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = LayoutMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.customView.line1.text = "Hello"
binding.customView.line2.text = "World"
}
}
Run Code Online (Sandbox Code Playgroud)
在我的 MainActivity 中,我可以使用绑定来查找 MyCustomView,但我无法在 MyCustomView 中进一步查找@id/line1 …
远程配置getString()在版本18.0.0和版本19.0.0之间返回不同的结果。
我尝试设置
org.gradle.jvmargs=-Dfile.encoding=UTF-8
systemProp.file.encoding=utf-8
Run Code Online (Sandbox Code Playgroud)
在里面 gradle.properties
我也尝试设置
compileOptions {
encoding = 'UTF-8'
}
Run Code Online (Sandbox Code Playgroud)
在 build.gradle
下面是代码片段
fun getRemoteString(key: String) {
val wording = FirebaseRemoteConfig.getInstance().getString(key)
Log.d(javaClass.simpleName, "wording= $wording")
return wording
}
Run Code Online (Sandbox Code Playgroud)
我希望Firebase Remote Config ????,可以像返回18.0.0一样返回,但是现在它返回ç»å¥é±è®,19.0.0。
我需要配置任何设置吗?
谢谢。