I have a issue in my app; in my app, I refine listviews adapter and it's items using buttons, but when I click a button like "Show all records", the items in the listview are grayed out.
I think the code speaks for itself:
show_all_Button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Rest_menu menu = new Rest_menu();
menu = (Rest_menu)v.getTag();
myAdapter adapter = new myAdapter(getApplicationContext(), menu.all_array);
listView.setAdapter(adapter);
}
});
as you can see, by clicking show_all_button, the listview's adapter sets to show all items, and the items are shown, but rows are grayed out. what can I do to make them Not grayed out? EDIT: after some coding, edited the adapter, and here's the code of the listview's adapter:
public class foodAdapter extends ArrayAdapter<Food> {
Context context;
public Food[] iteminarow;
public foodAdapter(Context context,Food[] iteminarow)
{
super(context, R.layout.listitem,iteminarow);
this.context=context;
this.iteminarow=iteminarow;
}
static class ViewHolder{
TextView foodname;
TextView foodprice;
TextView foodinfo;
public ViewHolder(TextView foodname,TextView foodprice,TextView foodinfo)
{
this.foodname=foodname;
this.foodprice=foodprice;
this.foodinfo=foodinfo;
}
}//end of ViewHolder
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
TextView name,price,info;
Food f = (Food)this.getItem(position);
if(convertView==null)
{
LayoutInflater LI = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = LI.inflate(R.layout.listitem,parent,false);
name=(TextView)convertView.findViewById(R.id.foodname);
price=(TextView)convertView.findViewById(R.id.foodprice);
info=(TextView)convertView.findViewById(R.id.foodinfo);
convertView.setTag(new ViewHolder(name, price, info));
}//end of if
else {
ViewHolder holder = (ViewHolder) convertView.getTag();
name = holder.foodname;
price = holder.foodprice;
info = holder.foodinfo;
}//end of else
name.setText(f.getName().toString());
price.setText(f.getPriceString());
info.setText(f.getInfo().toString());
return convertView;
}
}//end of adapter