質問

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?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top