Setting multiple custom elements to MultiAutoCompleteTextView : Android

前端 未结 2 1844
庸人自扰
庸人自扰 2020-12-15 11:48

Continuing from my previous post, I was able to set multiple elements to the MultiAutoCompleteTextView but I was not able to wrap those items with custom backg

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 12:31

    I think you have problem here:

    mMultiAutoCompleteTextView.setText(mMultiAutoCompleteTextView.getText().toString()+", "+sb);
    

    When you call mMultiAutoCompleteTextView.getText().toString(), you convert your spannableString to ordinary string, which can't hold background or smth else.

    Try to save your current SpannableStringBuilder somewhere and work like that:

    mBuilder.append(sb);
      mMultiAutoCompleteTextView.setText(mBuilder);
    

提交回复
热议问题