android studio actionbar 里fragment中listview无法显示的问题!急!!
publicclassFragment_CompletingextendsFragment{privateContextcontext;publicvoidonCreat...
public class Fragment_Completing extends Fragment {
private Context context;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
//setContentView(R.layout.activity_main);
View rootView = inflater.inflate(R.layout.fragment_completing, container, false);
ListView lv = (ListView)rootView.findViewById(R.id.listView);
ArrayList<HashMap<String, String>> lists = new ArrayList<HashMap<String, String>>();
HashMap<String,String> item=new HashMap<String, String>();
item.put("id","序号1");
item.put("job", "岗位名称1");
item.put("address", "工作地点1");
item.put("remark", "备注1");
lists.add(item);
item=new HashMap<String, String>();
item.put("id","序号2");
item.put("job", "岗位名称2");
item.put("address", "工作地点2");
item.put("remark", "备注2");
lists.add(item);
String[] from = new String[]{ "id", "job", "address" , "remark"};
int[] to = new int[]{ R.id.id, R.id.job, R.id.address, R.id.remark };
SimpleAdapter adapter = new SimpleAdapter(this.context, lists, R.layout.listview_completing, from, to);
lv.setAdapter(adapter);
return rootView;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
this.context = activity;
}
}
里面没有表格怎么办呢?
更多代码请移步
http://hi.baidu.com/khhljmgkvobbkrd/item/2c3419022ecaeff7a01034e4
万分感谢。 展开
private Context context;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
//setContentView(R.layout.activity_main);
View rootView = inflater.inflate(R.layout.fragment_completing, container, false);
ListView lv = (ListView)rootView.findViewById(R.id.listView);
ArrayList<HashMap<String, String>> lists = new ArrayList<HashMap<String, String>>();
HashMap<String,String> item=new HashMap<String, String>();
item.put("id","序号1");
item.put("job", "岗位名称1");
item.put("address", "工作地点1");
item.put("remark", "备注1");
lists.add(item);
item=new HashMap<String, String>();
item.put("id","序号2");
item.put("job", "岗位名称2");
item.put("address", "工作地点2");
item.put("remark", "备注2");
lists.add(item);
String[] from = new String[]{ "id", "job", "address" , "remark"};
int[] to = new int[]{ R.id.id, R.id.job, R.id.address, R.id.remark };
SimpleAdapter adapter = new SimpleAdapter(this.context, lists, R.layout.listview_completing, from, to);
lv.setAdapter(adapter);
return rootView;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
this.context = activity;
}
}
里面没有表格怎么办呢?
更多代码请移步
http://hi.baidu.com/khhljmgkvobbkrd/item/2c3419022ecaeff7a01034e4
万分感谢。 展开
1个回答
2014-03-17
展开全部
你的fragment_completing里面的标题那一栏的layout_height="fill_parent"了,怎么还可能显示下面的ListView。
你的lists 里面的数据,加来加去,将一个相同的item加了两次。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询