相关疑难解决方法(0)

由CursorLoader支持的AutoCompleteTextView

因此,我无法在使用自定义的同时扩展MultiAutoCompleteTextView和支持它.这个问题特别随着电话而上升.在其中有一个游标作为参数方法具有在第一调用此方法有效的和未封闭的光标.但是,后续调用会导致空游标或关闭游​​标.我猜这与管理如何有关. CursorLoaderTokenizermAdapter.setCursorToStringConverter();convertToString()LoaderManagerCursorLoader

如果我将setCursorToStringConverter()方法注释掉,那么我会根据我在此视图中输入的文本看到可用选项列表.但是,由于没有convertToString()实现terminateToken()方法,因此自定义方法Tokenizer不接收我想要的字符串,而是接收游标对象的代表字符串,因为游标尚未用于获取当前字符串值在得到的查询中的所需列的.

任何人都已经能够实现三类的组合(CursorLoader/LoaderManger,MultiAutoCompleteTextView,和Tokenizer)?

我是否朝着正确的方向前进,或者这根本不可能?

我已经能够实现一个自定义MultiAutoCompleteTextView支持SimpleCursorAdapter的自定义Tokenizer.我只是想知道是否有可能使用a来实现它CursorLoader,因为严格模式抱怨光标MultiAutoCompleteTextView没有被明确关闭.

任何帮助将不胜感激.

public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView
  implements LoaderManager.LoaderCallbacks<Cursor> {

    private final String DEBUG_TAG = getClass().getSimpleName().toString();
    private Messenger2 mContext;
    private RecipientsCursorAdapter mAdapter;
    private ContentResolver mContentResolver;
    private final char delimiter = ' ';
    private CustomMultiAutoCompleteTextView mView;

    // If non-null, this is the current filter the …
Run Code Online (Sandbox Code Playgroud)

android stringtokenizer autocompletetextview android-cursorloader

33
推荐指数
1
解决办法
1万
查看次数

HowTo:AutoCompleteTextView 作为微调器替代品 - 但在焦点流内

过去两天,我在这个问题上花费了最多的时间。实际上,我想要一个微调器,它的行为类似于 TextInputLayout 中的 EditText(花哨的提示,如果在上一个编辑文本中按下了下一个/输入键盘按钮,它就会流走并被选择/输入)。

这似乎是不可能的,所以我想出了这个:

    <android.support.design.widget.TextInputLayout
        android:id="@+id/newMeasure_layout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"


        app:layout_constraintEnd_toEndOf="@+id/title_layout"
        app:layout_constraintStart_toStartOf="@+id/title_layout"
        app:layout_constraintTop_toBottomOf="@+id/measureSpinner">

        <AutoCompleteTextView
            android:id="@+id/newMeasure"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:imeOptions="actionNext|flagNoExtractUi"
            android:singleLine="true"
            android:inputType="textNoSuggestions|textVisiblePassword"
            android:cursorVisible="false"


            android:hint="@string/measure"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"

            android:drawableTint="@color/secondaryColor"
            android:drawableEnd="@drawable/ic_arrow_drop_down_black_24dp"
            android:drawableRight="@drawable/ic_arrow_drop_down_black_24dp" />
    </android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

这可以防止键盘显示闪烁的光标,提供建议、更正、...

为了防止用户输入内容,但仍允许通过按 enter / next 来聚焦下一个输入,我在代码中设置了一个过滤器(它还检查文本在建议光标中是否可用)。

private AutoCompleteTextView mNewMeasure;
...
    mNewMeasure = root.findViewById(R.id.newMeasure);

    mNewMeasure.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            ((AutoCompleteTextView)view).showDropDown();
            return false;
        }
    });
    mNewMeasure.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            AutoCompleteTextView v = ((AutoCompleteTextView)view);
            if(b && v.getText().length() == 0) {
                v.showDropDown();
            } …
Run Code Online (Sandbox Code Playgroud)

android spinner autocompletetextview android-edittext

6
推荐指数
1
解决办法
1604
查看次数