android 仿網易新聞首頁框架


  

實現思路很簡單左側欄目是一個一個的 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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM