Android 展会产品的ArrayList不起作用
我有两个意向城市和产品。第一个应用程序开放城市意向展示和用户选择城市。现在,城市通行证将用于展示产品的产品意图。 我使用数组列表从php api获取数据,并在产品意图中向用户显示:Android 展会产品的ArrayList不起作用,android,arraylist,Android,Arraylist,我有两个意向城市和产品。第一个应用程序开放城市意向展示和用户选择城市。现在,城市通行证将用于展示产品的产品意图。 我使用数组列表从php api获取数据,并在产品意图中向用户显示: ArrayList<HashMap<String,String>> getDatalist; StringRequest stringRequest = new StringRequest(Request.Method.GET, jsonUrl, new R
ArrayList<HashMap<String,String>> getDatalist;
StringRequest stringRequest = new StringRequest(Request.Method.GET, jsonUrl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
obj = new JSONObject(response);
prdArray = obj.getJSONArray("prd");
for(int aind = 0 ; aind < 2; aind++) {
final JSONObject do_id = prdArray.getJSONObject(aind);
String email = do_id.getString("email");
String phone = do_id.getString("phone");
HashMap<String,String> map = new HashMap<>();
map.put("KEY_EMAIL",email);
map.put("KEY_PHONE",phone);
getDatalist.add(map);
Toast.makeText(getApplicationContext(),user_id, Toast.LENGTH_SHORT).show();
}
}catch (JSONException e) {
Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_SHORT).show();
}
回收水:
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// - get element from your dataset at this position
// - replace the contents of the view with that element
if (holder instanceof ViewHolderRow) {
HashMap<String,String> map = mDataset.get(position);
ViewHolderRow userViewHolder = (ViewHolderRow) holder;
userViewHolder.txtEmail.setText(map.get("KEY_EMAIL"));
userViewHolder.txtPhone.setText(map.get("KEY_PHONE"));
.....
public void onBindViewHolder(RecyclerView.ViewHolder,int位置){
//-在此位置从数据集中获取元素
//-用该元素替换视图的内容
if(视图的保持架实例HOLDERROW){
HashMap map=mDataset.get(位置);
ViewHolderRow userViewHolder=(ViewHolderRow)holder;
userViewHolder.txtEmail.setText(map.get(“KEY_EMAIL”);
userViewHolder.txtPhone.setText(map.get(“KEY_PHONE”);
.....
像这样用于循环
for(int aind = 0 ; aind < prdArray.size; aind++) {
//your code
}
for(int-aind=0;aind
for(int aind = 0 ; aind < prdArray.size; aind++) {
//your code
}