我的应用程序目前有一个自动完成下拉框,但看起来字体颜色是一种灰色,并且在填充列表时不可见。第二张图片显示了单击时下拉列表的外观。如何更改下拉列表的布局以将列表中的项目显示为不同的颜色,如黑色?
下图!
编辑
AlertDialog.Builder adb = new AlertDialog.Builder(SettingsMain.this);
LayoutInflater inflater = SettingsMain.this.getLayoutInflater();
final View searchlayout = inflater.inflate(R.layout.search_friend, null);
friend_name = (AutoCompleteTextView) searchlayout.findViewById(R.id.friend_name);
friend_name.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable editable) {
}
public void beforeTextChanged(CharSequence charSequence, int arg1, int arg2, int arg3) {
}
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
String text = charSequence.toString();
new MyAsyncTask("get").execute("http://10.0.2.2/jamtivia/webservice.php?type=get_friends&username="+text);
drop_down_adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_dropdown_item_1line,adapterList);
drop_down_adapter.notifyDataSetChanged();
friend_name.setAdapter(drop_down_adapter);
if (!friend_name.isPopupShowing()) {
friend_name.showDropDown();
}
for(int i =0;i < adapterList.size();i++)
Log.d("TEXT CHNGE", adapterList.get(i));
}
});
adb.setView(searchlayout)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String fname = friend_name.getText().toString();
Integer friend_id = null;
try{
friend_id = adapterListId.get(adapterList.indexOf(fname));
Log.d( "ECHO" , "text : " + name +"ID :"+ player_id+ " ID: " + friend_id);
String request = "http://10.0.2.2/jamtivia/webservice.php?type=add_friends&friendId="+friend_id+"&playerId="+player_id;
new MyAsyncTask("send").execute(request);
}catch(Exception e){Log.d( "PROBLEM SENDING" , "text : " + adapterList.indexOf(fname));}
return;
}
})
.setNegativeButton("Done", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
adb.show();
此外,就您在这段代码中所见,这是执行此功能的好方法吗?