listClass.add(new ListClass(json.getString("ProductId"), json
.getString("ProductPrice")));
}
list.setAdapter(new MyListAdapter(Fragment1.this, listClass));
しかし、クラス: MyListAdapter でエラーが発生しました:
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = LayoutInflater.from(fragment).inflate(
R.layout.pricelist, parent, false);
fragment1 クラスはフラグメントを拡張します。一方、rowView = layoutinflater.from(//i はここではコンテキストのみを拡張でき、フラグメントは拡張できません)。私に何ができる??
mylistadapter クラスを更新します。
public class MyListAdapter extends BaseAdapter {
private Fragment fragment;
private ArrayList<ListClass> listClass = new ArrayList<ListClass>();
public MyListAdapter(Fragment1 fragment1, ArrayList<ListClass> listClass1) {
this.fragment = fragment1;
this.listclass = listClass1;
}
@Override
public int getCount() {
return listClass.size();
}
@Override
public Object getItem(int position) {
return ListClass.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = LayoutInflater.from(fragment).inflate(
R.layout.pricelist, parent, false);
TextView text1 = (TextView) rowView.findViewById(R.id.title);
TextView text2 = (TextView) rowView.findViewById(R.id.details);
text1.setText(BeanClass.get(position).phoneName);
text2.setText(BeanClass.get(position).phonePrice);
return rowView;
}
}