只有视图容器才可添加子视图,
ListView lv = new ListView(this);//pop上的ListView lv.setLayoutParams(param);// List<String> area = new ArrayList<String>();//数据源 area.add("全部"); area.add("东湖区"); area.add("西湖区"); area.add("青山湖区"); area.add("青云谱区"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,area); lv.setAdapter(adapter); lv.setItemsCanFocus(false); lv.setPadding(left, top, right, bottom); view.addView(lv);//view加上ListView
设置间距,容器可设置pading,但是要LayoutParams设置Pading。子视图可以设置Margin,直接调用view.setMargin();