我必须在适配器类的列表视图项中单击图像时导航到另一个活动。这是我的适配器类:
public class RestaurantAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<String> rest,location,id;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
Context c;
public RestaurantAdapter(Activity a,Context context, ArrayList<String> restaurants, ArrayList<String> location2 ,ArrayList<String> restid) {
activity = a;
rest=restaurants;
location=location2;
id=restid;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// imageLoader=new ImageLoader(activity.getApplicationContext());
c=context;
}
public int getCount() {
return rest.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.listview_layout, null);
vi.setClickable(true);
vi.setFocusable(true);
TextView text=(TextView)vi.findViewById(R.id.txt);;
TextView f=(TextView)vi.findViewById(R.id.cur);;
TextView r=(TextView)vi.findViewById(R.id.resid);;
ImageView image=(ImageView)vi.findViewById(R.id.list_image);
text.setText(rest.get(position));
f.setText(location.get(position));
r.setText(id.get(position));
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(c,UserSettings.class);
intent.putExtra("id",id.get(position) );
intent.putExtra("resname", rest.get(position));
intent.putExtra("location", location.get(position));
c.startActivity(intent);
}
});
return vi;
}
但它在这条线上给了我例外
c.startActivity(intent);
有什么建议么??