在我的活动中,这一行(Home.this,android.R.layout.activity_home, searchResults));
中有一个错误,上面写着“activity_home 无法解决”,但是如果我按照教程之一中提到的那样给出 single_list_item_1,错误就会消失,因为这个错误我已经在 res 中检查了大写字母,然后清理了项目,但仍然无法摆脱这个。
searchBox.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
//get the text in the EditText
String searchString=searchBox.getText().toString();
int textLength=searchString.length();
//clear the initial data set
searchResults.clear();
for(int i=0;i<songsList.size();i++)
{
String playerName=songsList.get(i).get("title").toString();
if(textLength<=playerName.length()){
//compare the String in EditText with Names in the ArrayList
if(searchString.equalsIgnoreCase(playerName.substring(0,textLength)))
Toast.makeText(getApplicationContext(),playerName,1).show();
searchResults.add(songsList.get(i));
}
list.setAdapter(new ArrayAdapter<HashMap<String, String>>
(Home.this,android.R.layout.single_list_item, searchResults));
}
adapter.notifyDataSetChanged();
}
public void beforeTextChanged(CharSequence s, int start, int count,int after) {
}
public void afterTextChanged(Editable s) {
}
});