我有一個帶有MatrixCursor的AutoCompleteTextView作爲適配器。該AutoCompleteTextView有OnItemClickListener如下:AutoCompleteTextView上的getText()返回SpannableStringBuilder?
public class AutoCompleteListClickListner implements OnItemClickListener
{
private AutoCompleteTextView acView;
public AutoCompleteListClickListner(AutoCompleteTextView view)
{
this.acView = view;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
/* tv is the selected view in the dropdown */
TextView tv = (TextView) ((LinearLayout) view).getChildAt(0);
Log.d(AndroidLogTag, "Before:>>>>" + this.acView.getText().toString());
this.acView.setText(tv.getText().toString());
Log.d(AndroidLogTag, "After:>>>>" + this.acView.getText().toString());
}
}
當一個項目被選中我在日誌中看到以下
10-14 00:34:37.893: DEBUG/MyApp(19151): Before:>>>>[email protected]
10-14 00:34:37.912: DEBUG/MyApp(19151): After:>>>>Ankit V Jain
如果你看到的日誌中,Before
日誌條目中,getText()
返回SpannableStringBuilder
對象它的toString()
它返回一些對象標識符。
如何在點擊下拉項目之前獲取自動完成視圖的實際文本?