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