【发布时间】:2016-04-29 04:43:27
【问题描述】:
我正在使用从 github 找到的一个不错的 Material Design 编辑文本: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"/>
所以我希望通过浏览文件系统以编程方式填充编辑文本的值。因此,edittext 是可点击的,但不可聚焦,因此用户无法编辑接收到的文件的路径。现在这个 (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);
}
不知何故,这并没有更新 UI 上的文本。我也尝试过使用filePathValue.invalidate(),但这也没有帮助。
任何帮助表示赞赏。
【问题讨论】:
-
@MarkKeen 没用。但 stefno 的解决方案成功了。
标签: android android-edittext settext