SimpleAdapter中设定了 R.layout.listview_item


    private static final String TAG = "MainActivity";
    private List<Person> persons;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
  mButton = (Button) findViewById(R.id.button1);
          mListView = (ListView) findViewById(R.id.listView1);
          mButton.setOnClickListener(new MyOnClickListener());
}
 private class MyOnClickListener implements OnClickListener {
         @SuppressLint("ShowToast")
@Override
         public void onClick(View v) {
                 try {
                         // 得到Json解析成功之后数据
                         persons = JsonParse.getListPerson(urlPath);
                         List<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
                         for (int i = 0; i < persons.size(); i++) {
                                 HashMap<String, Object> map = new HashMap<String, Object>();
                                 map.put("id",persons.get(i).getId());
                                 map.put("name", persons.get(i).getName());
                                 map.put("password", persons.get(i).getPassword());
                                 map.put("age", persons.get(i).getAge());  
                                 map.put("sex",persons.get(i).getSex());
                                 map.put("hobby",persons.get(i).getHobby());
                                 map.put("city",persons.get(i).getCity());
                                 data.add(map);
                         }
                         SimpleAdapter _Adapter = new SimpleAdapter(MainActivity.this,
                                 data, R.layout.listview_item, new String[] { "id","name",
                                                 "password", "age","sex","hobby","city" }, new int[] { R.id.textView1,
                                                 R.id.textView2, R.id.textView3, R.id.textView4, R.id.textView5, R.id.textView6, R.id.textView7 });
                 mListView.setAdapter(_Adapter);
         } catch (Exception e) {
                 Toast.makeText(MainActivity.this, "解析失败", 2000).show();
                 Log.i(TAG, e.toString());
         }
       }


这里的lisR.layout.listview_item,, R.id.textView1,R.id.button1,,R.id.listView1在xml中怎么写。。才可以显示在应用上
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值