ui android需要解决的问题

1. layoutInflator

2. 在没有activity的情况下调用layout怎么实现

3.动画

4.webview

5.grid view中嵌套viewpager

6.不规则布局

JSONArray

ViewFilpper

ViewFlow

 

http://www.cnblogs.com/TerryBlog/archive/2012/02/17/2355753.html

 http://www.javacodegeeks.com/2013/04/android-tutorial-using-the-viewpager.html

public class MenuGridView {
	
	private View v;
	private JSONArray mJsonArray;
	
	//just for test
	

	public MenuGridView(LayoutInflater inflater, ViewGroup container) {
		v = inflater.inflate(R.layout.gridview, container, false);

	}

	public void PlainGridView(
			GridView gridview, Activity activity){
		//View v = inflater.inflate(R.layout.gridview, container, false);

		ArrayList<HashMap<String, Object>> menuImageItem = new ArrayList<HashMap<String, Object>>();
		for (int i = 0; i < 6; i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("ImageItem", R.drawable.submenu);
			map.put("TextItem", "The " + String.valueOf(i));
			menuImageItem.add(map);
		}
		GridViewAdapter menuItemAdapter = new GridViewAdapter(activity,
				menuImageItem, R.layout.gridmenuitem, new String[] {
						"ImageItem", "TextItem" }, new int[] { R.id.ItemImage,
						R.id.ItemText });
		gridview.setAdapter(menuItemAdapter);
	}
	
	public void ViewPagerGridView(int albumCount, ViewPager mViewPager, FragmentManager mFragMgr, GridView gridview, Activity activity){

		//ViewPager mViewPager = (ViewPager)findViewById(R.id.viewpager);
		//mViewPagerAdapter = new ViewPagerAdapter(this,mJsonArray);
		//mViewPager.setAdapter(mViewPagerAdapter);
		
		ArrayList<HashMap<String, Object>> menuImageItem = new ArrayList<HashMap<String, Object>>();
		//set 1
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("fragment", value);
		
		
		// Todo: use albumCount to design the fragment
		List<Fragment> fragmentList= new ArrayList<Fragment>(); 
		List<String> titleList = new ArrayList<String>();
		fragmentList.add(new ViewPagerFragment("1"));
		fragmentList.add(new ViewPagerFragment("status_page"));
		titleList.add("1_title");
		titleList.add("status page_title");
		ViewPagerFragmentAdapter mViewPagerAdapter;
		mViewPagerAdapter = new ViewPagerFragmentAdapter(mFragMgr,fragmentList,titleList);
		mViewPager.setAdapter(mViewPagerAdapter);
		
		
		//set the adapter for the gridview
		GridViewAdapter menuItemAdapter = new GridViewAdapter(activity,
				menuImageItem, R.layout.view_pager_fragment_demo2, new String[] {
						"ImageItem", "TextItem" }, new int[] { R.id.ItemImage,
						R.id.ItemText });
		
		
		gridview.setAdapter(menuItemAdapter);
		
	}


}

  

public class ViewPagerFragment extends Fragment {

	private String text;
	private TextView tv = null;

	// todo: 考虑将layout 也通过参数传进来,利于复用

	public ViewPagerFragment(String text) {
		super();
		this.text = text;

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		if (text.equals("main_page")) {
			
			
			View v = inflater.inflate(R.layout.gridview, container, false);
			GridView gridview = (GridView) v.findViewById(R.id.gridview);
			MenuGridView menuGridView = new MenuGridView(inflater, container);
			
			//test for the plain grid view
			//menuGridView.PlainGridView(gridview, (Activity) getActivity());
			
			//test for the grid view contains view pager 
			View v2 = inflater.inflate(R.layout.viewpagergrid,container,false);
			ViewPager mViewPager = (ViewPager)v2.findViewById(R.id.viewpagergrid);
			
			menuGridView.ViewPagerGridView(2, mViewPager, getActivity().getSupportFragmentManager(),gridview,(Activity) getActivity());

			return v;

		} 
		else if(text.equals("status_page")){
			View v = inflater.inflate(R.layout.view_pager_fragment_demo2,
					container, false);
			
			return v;
		}
		
		else{
			View v = inflater.inflate(R.layout.view_pager_fragment_demo,
					container, false);
			tv = (TextView) v.findViewById(R.id.viewPageText);
			tv.setText(text);
			return v;
		}

	}

}

  

posted on 2013-06-09 18:52  lauraxia  阅读(142)  评论(0编辑  收藏  举报

导航