在main_activity里放了一个ViewPager,里面添加了5个页面。
又在第1页里加了一个listview,然后在MainAvtivity.java里为ListView绑定数据,可是ListView显示不出来。
哪位大侠告诉我这是为什么啊?
public class MainActivity extends Activity implements OnCheckedChangeListener {
private ListView layout_1_listView;
private List<Map<String, Object>> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 设置窗口无标题
// requestWindowFeature(Window.FEATURE_NO_TITLE);
layOut_1_IniVariable();
}
private void layOut_1_IniVariable() {
// TODO Auto-generated method stub
Log.d("log", "=====================初始化listview");
View layout_1 = View.inflate(this, R.layout.layout_1, null);//找到第一个页面
layout_1_listView = (ListView) layout_1.findViewById(R.id.listView1);
SimpleAdapter adapter = new SimpleAdapter(this, getData(),
R.layout.layout_1_mlistview, new String[] { "depName",
"depInfo" }, new int[] { R.id.depName, R.id.depInfo });
layout_1_listView.setAdapter(adapter);
}
private List<Map<String, Object>> getData() {
list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("depName", "google 1");
map.put("info", "google 1");
list.add(map);
map = new HashMap<String, Object>();
map.put("depName", "google 2");
map.put("info", "google 2");
list.add(map);
map = new HashMap<String, Object>();
map.put("depName", "google 3");
map.put("info", "google 3");
list.add(map);
return list;
}
------解决方案--------------------
粗看了一下,看出一个问题
map.put("info", "XXXXXXXX");
应该是
map.put("depInfo", "XXXXXXXXX");
不过,又看到,你已经解决了。就不多看了。
祝你好运!