我正在使用从 github 找到的一个很好的材料设计编辑文本:https://github.com/rengwuxian/MaterialEditText https://github.com/rengwuxian/MaterialEditText
并将依赖项部分更新为:
dependencies {
compile 'com.rengwuxian.materialedittext:library:2.0.3'
}
edittext xml 定义如下:
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/device_file_location_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_file_location"
android:textAppearance="?android:attr/textAppearanceMedium"
android:enabled="true"
android:focusable="false"
android:clickable="true"
app:met_floatingLabel="normal"
app:met_floatingLabelText="@string/file_location"
app:met_singleLineEllipsis="true"
app:met_baseColor="#FCFBE3"
app:met_primaryColor="#FCFBE3"/>
因此,我期望通过浏览文件系统以编程方式填充编辑文本的值。因此,编辑文本是可点击的,但不可聚焦,因此用户无法编辑收到的文件的路径。现在这个(device_file_location_value
)编辑文本由从其他片段(实现文件浏览器的片段)接收的值进行更新,并在onCreateView
其片段:
Bundle bundle = getArguments();
String filePath = bundle.getString(FileBrowserFragment.PARAM_FILE_PATH);
if (filePath != null) {
filePathValue.setText(filePath);
bundle.remove(FileBrowserFragment.PARAM_FILE_PATH);
}
不知怎的,这并没有更新用户界面上的文本。我也尝试过使用filePathValue.invalidate()
但这也没有帮助。
任何帮助表示赞赏。
尝试用这种方法。
filePathValue.post(new Runnable() {
@Override
public void run() {
filePathValue.setText(filePath);
}
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)