I have this code which gets some data from a database
public List getAllObjects() {
List Objectslist = new ArrayList&
I suggest you update your classes like the following:
Objects.java:
public class Objects {
private int id;
private String name;
private String url;
public Objects() {
}
public Objects(int id, String name, String url) {
this.id = id;
this.name = name;
this.url = url;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
DBAdapter.java:
public class DBAdapter extends ArrayAdapter {
private static Uri[] mUrls = null;
private static String[] strUrls = null;
private String[] mNames = null;
private Cursor cc = null;
private Context mcontext;
private int layoutResourceId;
private List> listitems;
public DBAdapter(Context context, int layoutResourceId, List listitem) {
super(context, layoutResourceId, listitem);
this.layoutResourceId = layoutResourceId;
this.mcontext = context;
this.listitems = listitem;
System.out.println("entering adapter");
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
System.out.println("entering adapter1");
View row = convertView;
final ViewHolder holder;
if (row == null) {
LayoutInflater inflater = LayoutInflater.from(mcontext);
row = inflater.inflate(layoutResourceId, parent, false);
holder = new ViewHolder();
holder.imageTitle = (TextView) row.findViewById(R.id.textView);
holder.imageView = (ImageView) row.findViewById(R.id.imageView);
row.setTag(holder);
} else {
holder = (ViewHolder) row.getTag();
}
Objects item = getItem(position);
System.out.println("item.getUrl() ");
System.out.println(item.getUrl());
Picasso.with(mcontext).setIndicatorsEnabled(true);
holder.imageTitle.setText(item.getId());
Picasso.
with(mcontext).
load(item.getUrl())
.placeholder(R.drawable.logo)
.fit()
.noFade()
.into(holder.imageView);
holder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d("OnImageButton", "Clicked");
Intent intnt = new Intent(mcontext, SingleViewActivity.class);
intnt.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//Bitmap imageID=holder.imageView;
//intnt.putExtra("ImageId", imageID);
mcontext.startActivity(intnt);
Toast.makeText(mcontext, "intent",
Toast.LENGTH_LONG).show();
}
});
return row;
}
static class ViewHolder {
TextView imageTitle;
ImageView imageView;
}
}