if(tabId=="tab03"){
//获取管理者权限 android.app.FragmentManager manager=getFragmentManager(); FragmentTransaction transaction=manager.beginTransaction(); ListViewFragment2 fragment=new ListViewFragment2(); transaction.add(R.id.framlayout,fragment);//容器的ID transaction.commit();//提交事务 } 这里就是动态添加。。。。 然后 public class ListViewFragment2 extends Fragment{ private ListView listview; private SimpleAdapter simp_adapter; private List<Map<String,Object>>dataList; private ArrayAdapter<String>arr_adapter; private View view; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view=inflater.inflate(R.layout.fragment1, container, false); listview=(ListView) view.findViewById(R.id.listview1); dataList=new ArrayList<Map<String,Object>>(); simp_adapter=new SimpleAdapter(getActivity(), getdata(), R.layout.simpleadapter,new String[]{"pic","text"},new int[]{R.id.pic,R.id.text}); listview.setAdapter(simp_adapter); listview.setItemsCanFocus(true); } return view; } private List<Map<String,Object>> getdata() { for(int i=0;i<20;i++) { Map<String,Object>map=new HashMap<String,Object>(); map.put("pic",R.drawable.a); map.put("text","亚索"+i); dataList.add(map); } return dataList; } }
付费偷看金额在0.1-10元之间
一看你就是新手,哪有这样写的if(tabId=="tab03")
你每次都add一个Fragment,肯定走onCreateView,搜搜Fragment懒加载吧
一周热门 更多>