Android 使用自定义arrayadapter从JSON到listview截取数据

Android 使用自定义arrayadapter从JSON到listview截取数据,android,json,listview,android-volley,Android,Json,Listview,Android Volley,这是我的代码,运行良好。 我想从JSON数据中获取多个值(包括图像地址),并在listview的每一行中显示它们,但我做不到,我只能获取一个数据(标题)并将其放在简单列表中,如何用我自己的单行布局替换android.R.layout.simple\u list\u item\u 1?我是android新手,我不明白列表视图和行的循环在哪里 我想做的是从JSON获取一些数据,并在我的自定义行布局中显示它们,类似于google plus列表视图,带有图像、标题和描述 对不起,我的英语不好:) @覆盖

这是我的代码,运行良好。 我想从JSON数据中获取多个值(包括图像地址),并在listview的每一行中显示它们,但我做不到,我只能获取一个数据(标题)并将其放在简单列表中,如何用我自己的单行布局替换android.R.layout.simple\u list\u item\u 1?我是android新手,我不明白列表视图和行的循环在哪里

我想做的是从JSON获取一些数据,并在我的自定义行布局中显示它们,类似于google plus列表视图,带有图像、标题和描述

对不起,我的英语不好:)

@覆盖
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
上下文=这个;
setContentView(R.layout.activity\u read\u restaurants);
restaurantList=(ListView)findViewById(R.id.restaurantList);
final ArrayAdapter restaurantAdapter=新的ArrayAdapter(这是android.R.layout.simple\u list\u item\u 1,restaurantArray);
restaurantList.setAdapter(restaurantAdapter);
RequestQueue rq=Volley.newRequestQueue(this);
JsonObjectRequest jsonrequest=新的JsonObjectRequest(Request.Method.GET,feedURL,null,
新的Response.Listener(){
@凌驾
公共void onResponse(JSONObject响应){
试一试{
JSONArray restaurants=response.getJSONArray(“posts”);

对于(int i=0;i检查本教程以创建arrayadapter并在程序中使用它


它甚至实现了视图保持模式。

嗨,android.R.layout.simple_list_item_1是android系统的默认设置,只能有一个文本视图。用你自己的布局替换它,可以有多个文本视图并将其充气谢谢你的回答,我尝试过多次,我为行做了自己的布局,但我不知道它在哪里d如何获取数据并将文本(和或图像src)设置到我的布局项创建一个扩展ArrayAdapter的类并重写getView方法以膨胀自定义行可能的重复项
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    setContentView(R.layout.activity_read_restaurants);
    restaurantList = (ListView) findViewById(R.id.restaurantList);


    final ArrayAdapter<String> restaurantAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,restaurantArray);
    restaurantList.setAdapter(restaurantAdapter);

    RequestQueue rq = Volley.newRequestQueue(this);
    JsonObjectRequest jsonrequest = new JsonObjectRequest(Request.Method.GET,feedURL,null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    try {
                        JSONArray restaurants = response.getJSONArray("posts");
                        for (int i =0; i<restaurants.length(); i++){
                            restaurantArray.add(restaurants.getJSONObject(i).getString("title"));
                        }
                    } catch (JSONException e) {

                        e.printStackTrace();
                    }
                    restaurantAdapter.notifyDataSetChanged();
                }

            },new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(context, error.toString(), Toast.LENGTH_LONG).show();

                }
            });


    rq.add(jsonrequest);
}