21036


以下のコードでAutoCompleteTextが現状２文字以上入力した場合にsetCursorToStringConverterが起動します。  
１文字目で起動させたい場合はどのようにすればよいですか。

[code]

    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);
    
[/code]


CC BY-SA 3.0
2016-01-18T02:36:27.427
21019
2016-01-19T01:36:41.623
2016-01-19T01:36:41.623
14038
13247
question
android java
androidで予測変換機能を1文字目から起動させたい

[code]

    final AutoCompleteTextView inputTextView = (AutoCompleteTextView) findViewById(R.id.m_name);
    inputTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }
    
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (count == 1) {
                    inputTextView.setThreshold(0);
                }
            }
    
            @Override
            public void afterTextChanged(Editable s) {
    
            }
    });
    
[/code]

これでできます。テキスト入力前、入力後などは適宜上下のメソッドで可能です。


CC BY-SA 3.0
2016-01-18T12:36:56.193
21036
2016-01-18T12:36:56.193
14038
21019
answer