Pass img src to android view? -
i using volley
json data.
how use image src populate imageview? below response
json data dribbble. http://api.dribbble.com/shots/everyone?
the data give me image source
"image_url":"https://d13yacurqjgara.cloudfront.net/users/24831/screenshots/2112992/2015-06-18_19.51.18_copy.jpg"
how can use image source inside imageview
// build array jsonarray shots = response.getjsonarray("shots"); list<string> titles = new arraylist<string>(); (int i=0; < shots.length(); i++) { jsonobject post = shots.getjsonobject(i); string title = post.getstring("title"); titles.add(title); } // can see taking data , turning strings.. string[] titlearr = new string[titles.size()]; titlearr = titles.toarray(titlearr); // set adapter listadapter dribbblefeedadapter = new arrayadapter<string>(mainactivity.this, r.layout.feed_card,r.id.info_text,titlearr); // set listview listview dribbbledatalistview = (listview) findviewbyid(r.id.dribbblefeedlistview); // set listview adapter dribbbledatalistview.setadapter(dribbblefeedadapter); // check data log.d("this array", "arr: " + arrays.tostring(titlearr));
feed_card.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/card_layout" android:layout_width="fill_parent" android:layout_height="wrap_content"> <!-- cardview contains textview --> <android.support.v7.widget.cardview xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" card_view:cardcornerradius="2dp"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <textview android:layout_weight="1" android:id="@+id/info_text" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <imageview android:layout_width="match_parent" android:layout_height="100dp" android:layout_gravity="center" android:background="#aaa" android:id="@+id/dribbble_img"/> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <button android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="like" /> <button android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="share" /> </linearlayout> </linearlayout> </android.support.v7.widget.cardview> </linearlayout>
Comments
Post a Comment