[英]Textview not wrapping text inside list
我想使用SimpleCursorAdapter
在SearchView
上显示项目。 我的代码是这样的:
mAdapter = new SimpleCursorAdapter(this,
R.layout.my_text_view,
null,
new String[]{"cityName"},
new int[] { android.R.id.text1},
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
SearchManager searchManager = (SearchManager) getSystemService(this.SEARCH_SERVICE);
SearchView sv = (SearchView) findViewById(R.id.svBusqueda);
sv.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
sv.setSuggestionsAdapter(mAdapter);
sv.setIconifiedByDefault(false);
sv.setQueryHint("cityName");
我用于搜索项的文本视图布局:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:scrollHorizontally="false"
android:singleLine="false"
android:maxLines="100"
android:gravity="center_vertical"
android:layout_weight="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall" />
搜索完美运行,但由于某种原因,我无法将文本包裹在TextView
。 ¿我错过了什么?
您必须使用 2 个参数:
android:ellipsize="none" : the text is not cut on textview width
android:scrollHorizontally="false" the text wraps on as many lines as necessary
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.