开发者

Need help on AutoCompleteTextView for Searching

I have implemented an AutoCompleteTextView for searching. Is AutoCompleteTextView supported in all SDK versions and targets, because when I tried this sample it shows an empty dropdown list. When I used the same in my application for parsed content placed inside a string array, I'm getting an Exception.

Log.v("Length of a",Integer.toString(a.length));
try{
    wv.setVisibility(View.GONE);
    place_list.setVisibility(View.VISIBLE);
    Log.v("Length of a222222",Integer.toString(a.length));

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(Bru_Maps.this, android.R.layout.simple_dropdown_item_1line, a);
    textView.setAdapter(adapter);
} catch(Exception e) {                  
    Log.v("Error","search开发者_高级运维_name"+e);     
}

The above given code prints the log well but it returns a NullPointerException.

ArrayAdapter<String> adapter = new ArrayAdapter<String>(Bru_Maps.this, android.R.layout.simple_dropdown_item_1line, a);


As I can see from the example, you need to set the Threshold value to 1, if you want to see the list of available countries after you type the first character in the TextView. Use autoCompleteTextView.setThreshold(1) to see it in action.


Can't add comments yet, so... What is the datatype for a? You wrote that it is a string when it needs to be an array of strings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜