毕业论文

打赏
当前位置: 毕业论文 > 计算机论文 >

基于Android的大学生生活小助手设计与开发(7)

时间:2016-12-22 19:55来源:毕业论文
ftIndicatorTabHost.addTab(tab3, WorkFragment.class, getBundle(求职)); ftIndicatorTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId)


    ftIndicatorTabHost.addTab(tab3, WorkFragment.class, getBundle("求职"));
    ftIndicatorTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            toolbar.setTitle(tabId);
        }
    });
}

private View getIndicatorView(final String title, int iconId) {
    View indicatorView = UIUtils.inflate(R.layout.tab_indicator);
    ImageView imag_tab = (ImageView) indicatorView.findViewById(R.id.imag_tab);
    imag_tab.setImageResource(iconId);
    return indicatorView;
}

private Bundle getBundle(String data) {
    Bundle bundle = new Bundle();
    bundle.putString("data", data);
    return bundle;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        drawerToggle.onOptionsItemSelected(item);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
5.2功能实现
5.2.1 新闻模块
用户进入热点新闻界面,即可浏览到实时热点新闻列表,每个列表项点击进去之后可以进入新闻详情界面获取该项新闻的详细信息。新闻模块如图5.2所示:

 
图5.2 新闻模块图

主要实现代码如下所示:
private ArrayList<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> hotNewsListData;
private int pageNum = 1;

@Override
protected ArrayList<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> requestData() {
    pageNum = 1;
    hotNewsListData = loadNewsData(pageNum);
    return hotNewsListData;
}

private ArrayList<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> loadNewsData(int pageNum) {
    HotNews hotNewsData = null;
    ArrayList<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> hotNewsListData = null;
    try{
        String urlString = Url.getNewsDataUrl(pageNum);
        HttpHelper.HttpResult httpResult = HttpHelper.get(urlString);
        String resultString = httpResult.getString();
        LogUtil.e("resultString--"+resultString);
        hotNewsData = processNewsData(resultString);
        if(hotNewsData!=null){
            if(hotNewsData.getShowapi_res_code()==-1){
                hotNewsListData = new ArrayList<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity>();
            }else {
                hotNewsListData =           (ArrayList<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity>) hotNewsData.getShowapi_res_body().getPagebean().getContentlist();
                ArrayList<HotNews.ShowapiResBodyEntity.PagebeanEntity.ContentlistEntity> uselessData = 基于Android的大学生生活小助手设计与开发(7):http://www.youerw.com/jisuanji/lunwen_1423.html
------分隔线----------------------------
推荐内容