實現思路很簡單左側欄目是一個一個的 Fragment 的,點擊時動態替換各個 Fragment 到當前 Activity 中。
關鍵代碼:
public void loadFragment(Map<String, Object> map) { if (map == null) { return; } try { getSlidingMenu().toggle(); String title = (String) map.get("title"); if (currentTitle == null || !currentTitle.equals(title)) { currentTitle = title; // set title this.title.setText(title); Class<?> cls = (Class<?>) map.get("class"); String tag = (String) map.get("tag"); Fragment fragment = (Fragment) cls.newInstance(); // Insert the fragment by replacing any existing fragment FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.fragment_content, fragment, tag).commit(); } } catch (Exception e) { e.printStackTrace(); } }
首頁布局:
1 SliddingMenu + ViewPagerIndicator
2 JSON 解析 FastJson
3 網絡請求 Volley
4 sqlite 數據庫簡單封裝,主要處理數據庫版本升級問題
5 微信、微博 API 簡單封裝
6 代碼混淆
。。。。。。
github: https://github.com/lesliebeijing/MyAndroidFramework.git