androidで予測変換機能を1文字目から起動させたい
以下のコードでAutoCompleteTextが現状2文字以上入力した場合にsetCursorToStringConverterが起動します。
1文字目で起動させたい場合はどのようにすればよいですか。
AutoCompleteTextView inputTextView = (AutoCompleteTextView) findViewById(R.id.m_name);
Cursor m_cursor = db3.query(DB_TABLE, new String[]{"rowid as _id", "n_data" },null, null,null, null, null);
SimpleCursorAdapter M_adapter2 = new SimpleCursorAdapter(getApplicationContext(),
android.R.layout.simple_spinner_dropdown_item,
m_cursor,
new String[]{"n_data"},
new int[]{android.R.id.text1},
0) {
};
M_adapter2.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
@Override
public String convertToString(Cursor m_cursor) {
return m_cursor.getString(m_cursor.getColumnIndex("n_data"));
}
M_adapter2.setFilterQueryProvider(new FilterQueryProvider() {
public Cursor runQuery(CharSequence constraint) {
String str = constraint.toString();
str = "%" + str + "%";
helper = new DBOpenHelper(ItemListActivity.this);// DB作成
Cursor m_cursor = helper.getReadableDatabase().query(
DB_TABLE4, new String[]{"rowid as _id", "n_data"},
"n_data LIKE '' || ? || '%' ", new String[]{str},
null,null, null);
return m_cursor;
}
});
inputTextView2.setAdapter(M_adapter2);