Sorry.... I'm new in android....

对不起....我在安卓....新

I have done such schema: i created listview in my activity, and put on it adapter with own activity as in all tutorials...

我已经完成了这样的模式:我在活动中创建了listview,并将自己的活动放在it适配器上,就像在所有教程中一样……

But now i must to go further and create more complicated activity: on every my listview adapter view i must put another loop with data => other listview with adapter... Is it real?

但是现在我必须更进一步,创建更复杂的活动:在我的listview adapter视图上,我必须在data =>和listview with adapter…这是真的吗?

Here is my code(i do it in education goal):

这是我的代码(我在教育目标中做的):

protected void onCreate(Bundle savedInstanceState) {
        String bank;
        bank = this.getIntent().getStringExtra("Bank_id");
        url = "http://192.168.1.4:3000/exchanger_lists/get_bank_exchanger_list/"+bank+".json";
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bank_exchangers_list);

        // Hashmap for ListView
        ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();

        // Creating JSON Parser instance
        JSONParser jParser = new JSONParser();

        // getting JSON string from URL
        JSONObject json = jParser.getJSONFromUrl(url);

        try {
            // Getting Array of Contacts
            banks = json.getJSONArray(TAG_Exchangers);

            // looping through All Contacts
            for(int i = 0; i < banks.length(); i++){
                JSONObject c = banks.getJSONObject(i);

                // Storing each json item in variable
                String id = c.getString(TAG_ID);
                String name = c.getString(TAG_NAME);
                String address = c.getString(TAG_address);
                String location_name = c.getString(TAG_location_name);
                String latitude = c.getString(TAG_latitude);
                String longitude = c.getString(TAG_longitude);
                String exchanger_type_name = c.getString(TAG_exchanger_type_name);

                HashMap<String, String> map = new HashMap<String, String>();


                map.put(TAG_ID, id);
                map.put(TAG_NAME, name);
                map.put(TAG_address, address);
                map.put(TAG_location_name, location_name);
                map.put(TAG_latitude, latitude);
                map.put(TAG_longitude, longitude);
                map.put(TAG_exchanger_type_name, exchanger_type_name);


                // adding HashList to ArrayList
                contactList.add(map);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }


        ListAdapter adapter = new SimpleAdapter(this, contactList,
                R.layout.bank_exchanger_list_element,
                new String[] { TAG_NAME, TAG_location_name, TAG_address, TAG_exchanger_type_name, TAG_latitude, TAG_longitude }, new int[] {
                        R.id.bank_e_n, R.id.nas_punkt_e_n , R.id.adress_obm_e_n , R.id.tip_obm_e_n , R.id.shirota_e_n , R.id.dolgota_e_n });

        setListAdapter(adapter);
    }

i need to parse json children for each TAG_Exchangers and add in as an adapter for adapter listAdapter adapter = new SimpleAdapter(this, contactList, .......

我需要为每个TAG_Exchangers解析json子程序,并将其作为适配器添加到适配器listAdapter = new SimpleAdapter(this, contactList, the…)

Is it real? And how to do it?

这是真的吗?怎么做呢?

1 个解决方案

#1


0

why not using BaseAdapter , where you rule everything related to how it looks and how it uses the data? just implement getCount,getItem, and getView .

为什么不使用BaseAdapter呢?在这里,您可以对与它的外观和数据使用方式相关的所有内容进行管理。只需要实现getCount、getItem和getView。

for more information about listView, watch "the world of listView" lecture.

有关listView的更多信息,请观看“listView的世界”讲座。

更多相关文章

  1. 适配器模式和外观模式

随机推荐

  1. 项目里文件名永远不要用中文!永远不要!
  2. 每日一技|活锁,也许你需要了解一下
  3. 深入剖析 RSA 密钥原理及实践
  4. 天啦噜!生产机器连接数飙升到上万,背后发生
  5. 别只用 Selenium,新神器 Pyppeteer 绕过淘
  6. Android中ADT插件的安装
  7. 这个软件真不简单
  8. 为什么你就不能加个空格呢?
  9. 每日一技|巧用 Telnet 调试 Dubbo 服务
  10. Azure Lab Service 体验