首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Android文本视图中显示字符串

在Android文本视图中显示字符串
EN

Stack Overflow用户
提问于 2018-06-03 03:34:30
回答 1查看 68关注 0票数 -1

我正在尝试在文本视图1和文本视图2中显示字符串item_1item_2

在一些专家的帮助下,我创建了下面的代码。

如何在文本视图1和文本视图2中显示字符串item_1item_2

我的Java代码:

代码语言:javascript
复制
public class Prices extends AppCompatActivity {
    TextView item_1 , item_2 ,a3 ,a4 ,a5 ,a6;
    String url = "https://000000/app/almaraa/show.php";
    RequestQueue requestQueue;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_prices);
        TextView item_1 = (TextView) findViewById(R.id.item_1);
        TextView item_2 = (TextView) findViewById(R.id.item_2);
        requestQueue = Volley.newRequestQueue(this);
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url,null,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        final Globalv globalv = (Globalv) getApplicationContext();
                        try {
                            JSONArray jsonArray = response.getJSONArray("allmess");
                            for (int i = 0; i < response.length(); i++) {
                                JSONObject respons = jsonArray.getJSONObject(i);
                                String id = respons.getString("id");
                                String item_1 = respons.getString("item_1");
                                String item_2 = respons.getString("item_2");
                            }
                            JSONObject respons2 = jsonArray.getJSONObject(0);
                            String id = respons2.getString("id");
                            globalv.setTotal_threads(Integer.parseInt(String.valueOf(id)));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }

                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("VOLLEY", "ERROR");
            }
        }
        );
        requestQueue.add(jsonObjectRequest);
    }
}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50660466

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档