0

Help please!

In my application I use Android-UiTableView ( thiagolocatelli / android-uitableview ) and AQuery ( androidquery / androidquery )

My task is to make the loading of data from json array and load image from URL. Load a list without pictures I was able to:

jgall = json.getJSONArray("gall");                  
int z = 0;
  for(int i = 0; i < jgall.length(); i++){
      JSONObject c = jgall.getJSONObject(i);
      tableView.addBasicItem(c.getString("name"), c.getString("place"));
  }

I try to show a customized view and nothing happens

LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout view      = (RelativeLayout) mInflater.inflate(R.layout.custom_view,null); 
String iurl              = c.getString("img");
aq.id(R.id.img).image(iurl, false, true);                       
ViewItem viewItem        = new ViewItem(view);
tableView.addViewItem(viewItem);

Tell me it's real to make using Android-UiTableView? if so! how?

cjp2600
  • 31
  • 1
  • 6
  • I think you are looking for this: [Android – Asynchronous image loading in ListView](http://www.technotalkative.com/android-asynchronous-image-loading-in-listview/) – Paresh Mayani Oct 23 '12 at 10:19

1 Answers1

2

I have done this by modifying the library code myself.

I have added the following constructor at UITableView.java:

public void addBasicItem(Drawable drawable, String title, String summary) {
    mItemList.add(new BasicItem(drawable, title, summary));
}

And the following at BasicItem.java:

public Drawable getDDrawable() {
    return dDrawable;
}

public BasicItem(Drawable ddrawable, String _title, String _subtitle) {
    this.dDrawable = ddrawable;
    this.mTitle = _title;
    this.mSubtitle = _subtitle;
}

And once again modified the setupBasicItem method at UITableView.java file:

((ImageView) view.findViewById(R.id.image)).setBackgroundDrawable(item.getDDrawable());

Finally, at your code add the following:

URL newurl = new URL("http://www.example.com/example.png"); 
Bitmap bmp = BitmapFactory.decodeStream(newurl.openConnection() .getInputStream());
Drawable drawable = new android.graphics.drawable.BitmapDrawable(getResources(),bmp);

tableView.addBasicItem(drawable, "Title", "SubTitle");

Hope it helps, cause it works for me.

jkanini
  • 376
  • 4
  • 8
  • Worked perfectly! Should be obvious, of course, but you also have to add a private Drawable dDrawable to BasicItem.java. – MacD Jan 08 '13 at 11:37