Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否将img src传递给android视图?_Android - Fatal编程技术网

是否将img src传递给android视图?

是否将img src传递给android视图?,android,Android,我正在使用volley获取一些JSON数据 如何使用image src填充ImageView?下面的response是来自Dribble的json数据 数据将给我一个图像源 “图像url”:https://d13yacurqjgara.cloudfront.net/users/24831/screenshots/2112992/2015-06-18_19.51.18_copy.jpg“ 如何在我的ImageView // BUILD THE ARRAY JSONArray shots = res

我正在使用
volley
获取一些JSON数据

如何使用image src填充ImageView?下面的
response
是来自Dribble的json数据

数据将给我一个图像源

“图像url”:https://d13yacurqjgara.cloudfront.net/users/24831/screenshots/2112992/2015-06-18_19.51.18_copy.jpg“

如何在我的
ImageView

// BUILD THE ARRAY
JSONArray shots = response.getJSONArray("shots");
List<String> titles = new ArrayList<String>();
for (int i=0; i < shots.length(); i++) {
    JSONObject post = shots.getJSONObject(i);
    String title = post.getString("title");
    titles.add(title);
}

// You can see I am just taking that data and turning it into strings..
String[] titleArr = new String[titles.size()];
titleArr = titles.toArray(titleArr);

// SET THE ADAPTER
ListAdapter dribbbleFeedAdapter = new ArrayAdapter<String>(MainActivity.this,
        R.layout.feed_card,R.id.info_text,titleArr);
// SET THE LISTVIEW
ListView dribbbleDataListView = (ListView) findViewById(R.id.dribbbleFeedListView);
// SET THE LISTVIEW ADAPTER
dribbbleDataListView.setAdapter(dribbbleFeedAdapter);
// CHECK THE DATA
Log.d("this is my array", "arr: " + Arrays.toString(titleArr));
//构建数组
JSONArray shots=response.getJSONArray(“shots”);
列表标题=新的ArrayList();
对于(int i=0;i
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">
    <!-- A CardView that contains a 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>


像这样吗?我真的不明白这个问题。如果您有图像文件的URL,则需要下载该文件,在本地创建位图并将其用于
ImageView
ImageView
类不能直接使用远程URL作为其源。在android中使用URL中的图像的最佳方式是什么?它不必是ImageView。