1.이 어댑터의 ListViewjava.lang.NullPointerException이 ListViewAdapter.getView (ListViewAdapter.java:60)이
여기public class ListViewAdapter extends BaseAdapter {
// Declare Variables
Context context;
LayoutInflater inflater;
ArrayList<HashMap<String, String>> data;
ImageLoader imageLoader;
HashMap<String, String> resultp = new HashMap<String, String>();
public ListViewAdapter(NewsFragment newsFragment,
ArrayList<HashMap<String, String>> arraylist) {
this.context = context;
data = arraylist;
imageLoader = new ImageLoader(context);
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
public View getView(final int position, View convertView, ViewGroup parent) {
//protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Declare Variables
TextView productname;
TextView productid;
TextView producttype;
ImageView image;
가 문제이다 인플레이터 프래그먼트에 통합이다 = (LayoutInflater에서) convertView.getContext() .getSystemService (Context.LAYOUT_INFLATER_SERVICE);
// inflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); convertView가 처음에 널 (null)이 될 것이기 때문에
enter code here
View itemView = inflater.inflate(R.layout.listview_item, parent, false);
// Get the position
resultp = data.get(position);
// Locate the TextViews in listview_item.xml
productname = (TextView) itemView.findViewById(R.id.product);
productid = (TextView) itemView.findViewById(R.id.dateOfInput);
producttype = (TextView) itemView.findViewById(R.id.productprice);
// Locate the ImageView in listview_item.xml
image = (ImageView) itemView.findViewById(R.id.flag);
// Capture position and set results to the TextViews
productname.setText(resultp.get(NewsFragment.PRODUCTNAME));
productid.setText(resultp.get(NewsFragment.PRODUCTPRICE));
producttype.setText(resultp.get(NewsFragment.DATEOFINPUT));
// Capture position and set results to the ImageView
// Passes flag images URL into ImageLoader.class
imageLoader.DisplayImage(resultp.get(NewsFragment.IMAGE), image);
// Capture ListView item click
itemView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// Get the position
resultp = data.get(position);
Intent intent = new Intent(context, SingleItemView.class);
// Pass all data rank
intent.putExtra("productname",resultp.get(NewsFragment.PRODUCTNAME));
// Pass all data country
intent.putExtra("productid", resultp.get(NewsFragment.PRODUCTPRICE));
// Pass all data population
intent.putExtra("producttype", resultp.get(NewsFragment.DATEOFINPUT));
// Pass all data flag
intent.putExtra("image", resultp.get(NewsFragment.IMAGE));
// Start SingleItemView Class
context.startActivity(intent);
}
});
return itemView;
}
}
여기서'ListViewAdapter' 클래스 생성자에 컨텍스트를 전달하고 있습니까? –
imageLoader = 새로운 ImageLoader (컨텍스트); – user3414330