Hi and thanks for reading.
I have a problem with my android apps navigation drawer where I cannot change the color from blue - I have went over all the other questi
ListDrawer onItemClickListener:
final CustomListAdapter myadapter;
mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
selectItem(position);
myadapter.setSelectedItem(position);
}
In custom adapter:
public class CustomListAdapter extends ArrayAdapter {
private final Activity context;
private final String[] itemname;
int mSelectedItem;
public CustomListAdapter(Activity context, String[] itemname ) {
super(context, R.layout.drawer_list_item, itemname);
// TODO Auto-generated constructor stub
this.context = context;
this.itemname = itemname;
}
public void setSelectedItem(int selectedItem) {
this.mSelectedItem = selectedItem;
}
public View getView(final int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView = inflater.inflate(R.layout.drawer_list_item, null, true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.textitem);
String iname = itemname[position];
txtTitle.setText(iname);
txtTitle.setTypeface(tf);
if (position == mSelectedItem) {
txtTitle.setTextColor(getContext().getResources().getColor(R.color.white));
} else {
txtTitle.setTextColor(getContext().getResources().getColor(R.color.normal));
}
return rowView;
}
}
In colors.xml
#ffffff
#ef3272