我有LinearLayout和内部2 TextView都有选框,当我在第一次更新文本然后第二个TextView重新启动选框.
<LinearLayout
android:id="@+id/panel"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/first"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:gravity="bottom|center_horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true" />
<TextView
android:id="@+id/second"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:gravity="top|center_horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我发现如果为R.id.first和R.id.second我设置layout_width="320dp"的效果不会发生.但我想设置android:layout_width="match_parent"一些解决方法?
我发现类似的问题,但没有解决方案: Android,RelativeLayout在同一RelativeLayout中更改ImageView时重新启动Marquee-TextView
如何在android中将contentDescription添加到ListPreference.必须在列表中使用contentDescription
我有几次在我的偏好布局ListPreference wyich看起来像这样
<ListPreference
android:entries="@array/entries"
android:entryValues="@array/entryValues"
android:key="keylist_1"
android:title="@string/setting"
android:layout="@layout/custom_checkbox_preference" />
Run Code Online (Sandbox Code Playgroud)
每个使用相同的布局.布局custom_checkbox_preference如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true" />
<TextView
android:id="@+android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@android:id/title" />
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我需要添加标题contentDescription如何访问它?
我尝试添加到ListPreference:
android:hint="@string/desc_setting"
android:contentDescription="@string/desc_setting"
Run Code Online (Sandbox Code Playgroud)
但这不行.我也无法将其添加到标题textview中的custom_checkbox_preference,因为它被其他ListPreferences使用.
由于jcenter()删除一些较旧的libs的问题,我决定更新我的项目.所以现在我有:
gradle: 4.6
Run Code Online (Sandbox Code Playgroud)
和:
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:3.0.0'
Run Code Online (Sandbox Code Playgroud)
我几乎解决了每一个依赖,但我得到了
Failed to resolve: monitor
Run Code Online (Sandbox Code Playgroud)
没有任何线索是什么监视器;(
我开始新的电视应用程序,现在我需要为流的设置质量、流的语言等开发动态首选项。所以我计划使用 android.preference 库并根据流数据动态生成性能。但是在https://developer.android.com/guide/topics/ui/settings.html 上是
注意:本指南介绍了如何使用 AndroidX 首选项库。从 Android 10 开始,平台 android.preference 库已弃用。
但是没有重定向到替换。那么用什么来代替 android.preference 库呢?
在该指南上还请注意:
注意:本指南假设您使用的是 androidx.preference:preference :1.1.0-alpha04 或更高版本。某些功能在旧版本的库上可能不可用。
所以androidx.preference:preference会被弃用。
我刚开始在准备测试的 android(替换 Dagger 2)项目中使用 Koin lib。我在模块中的 android 应用上下文有问题:
val M = module {
val ctx = androidApplication() //here error
}
Run Code Online (Sandbox Code Playgroud)
Koin 在 App 类中启动:
import android.app.Application
import android.content.Context
import org.koin.android.ext.android.startKoin
class App : Application() {
override fun onCreate() {
super.onCreate()
startKoin(this, listOf(M))
}
}
Run Code Online (Sandbox Code Playgroud)
我得到日志:
D/App: onCreate()
I/KOIN: [context] create
E/KOIN: [ERROR] - Error while resolving instance for class 'android.app.Application' - error: org.koin.error.NoBeanDefFoundException: No compatible definition found for type 'Application'. Check your module definition
Run Code Online (Sandbox Code Playgroud)
并且应用程序崩溃。我是否错过了 Koin 配置中的某些内容?在目标项目中,我有几个深深依赖于应用程序上下文的模块。而且我不想使用对这个上下文的全局引用。
我有包含许多hangul字符的文件.例如:
?
?
?
?
?
?
?
?
?
?
?
Run Code Online (Sandbox Code Playgroud)
我想使用linux排序来排序文件中的行,但排序不起作用.它给了我:
?
?
?
?
?
?
?
?
?
?
?
Run Code Online (Sandbox Code Playgroud)
因此,sort只对空格进行排序.怎么排序呢?
假设有一个带有属性列表的类 A:
class A {
val list = mutableListOf<String>()
fun addAText() {
list.add("a text")
}
}
Run Code Online (Sandbox Code Playgroud)
但现在不仅方法addAText()可以将字符串添加到列表中,而且来自世界各地的每个人都可以。
所以我将上面的代码重写为:
class A {
private val mutList = mutableListOf<String>()
val list: List<String>
get() = mutList
fun addAText() {
mutList.add("a text")
}
}
Run Code Online (Sandbox Code Playgroud)
那么问题是:有更好的方法吗?像任何语法支持或标准 kotlin 库一样?额外的私有属性似乎不是一个优雅的解决方案。