我已经保存了大约 6 行保存在共享首选项中,每行包含名称、描述、价格等。我有一个列表,我必须在从共享首选项中检索到的每一行中填充名称、描述、价格。如何获取行中的所有数据并填充列表?
我已经做好了
public class LazyAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater=null;
private ArrayList<HashMap<String, Object>> data;
//public ImageLoader imageLoader;
int i=0;
public LazyAdapter(Activity a) {
activity = a;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.order_list, null);
TextView orderDishDescription = (TextView)vi.findViewById(R.id.orderDishDescription);
TextView OrderDishName = (TextView)vi.findViewById(R.id.OrderDishName);
TextView OrderDishPrice = (TextView)vi.findViewById(R.id.OrderDishPrice);
ImageView imageview=(ImageView) vi.findViewById(R.id.list_image_order);
//ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); /
//HashMap<String, Object> song = new HashMap<String, Object>();
// song = data.get(position);
Log.i("iiiiii "," " +i++);
// Log.i("objj.Get_O_Id() ",objj.Get_O_Id());
// Log.i("objj.GetProductName() ",objj.GetProductName());
// Log.i("objj.GetDescription() ",objj.GetDescription());
//
OrderDishPrice.setText(OrderSharedPrefences.getDish_Price(getApplicationContext()));
OrderDishName.setText(OrderSharedPrefences.getUserName(getApplicationContext()));
orderDishDescription.setText(OrderSharedPrefences.getDish_Description(getApplicationContext()));
//imageview.setImageBitmap(objj.GetImage());
return vi;
}
}