private void initView() { // scrollView_course_detail = (ScrollView) mView.findViewById(R.id.scrollView_course_detail); // 设置 scrollView 定位到顶部 ll_course_detail = (LinearLayout) findViewById(R.id.ll_course_detail); ll_course_detail.setFocusable(true); ll_course_detail.setFocusableInTouchMode(true); ll_course_detail.requestFocus(); mLayoutInflater = LayoutInflater.from(this); // 找到TabHost mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); mAbSlidingPlayView = (AbSlidingPlayView) findViewById(R.id.mAbSlidingPlayView); mAbSlidingPlayView.setNavHorizontalGravity(Gravity.CENTER); // mAbSlidingPlayView.setParentHScrollView(menuLayout); mAbSlidingPlayView.startPlay(); // 得到fragment的个数 int count = mFragmentArray.length; for (int i = 0; i < count; i++) { // 给每个Tab按钮设置图标、文字和内容 TabSpec tabSpec = mTabHost.newTabSpec(mTextArray[i]).setIndicator(getTabItemView(i)); Bundle bundle = new Bundle(); bundle.putString(Constants.KEY_ID, id); // 将Tab按钮添加进Tab选项卡中 mTabHost.addTab(tabSpec, mFragmentArray[i], bundle); // 设置Tab按钮的背景 mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.selector_detail_tab); } titlebar = (TitleBar) findViewById(R.id.index_titlebar); titlebar.setTitleBarTitle(title); ivShare = (ImageView) findViewById(R.id.title_share); btZixun = (Button) findViewById(R.id.bt_book); btBuy = (Button) findViewById(R.id.bt_buy); dialog = new CustomProgressDialog(this, R.string.laoding_tips, R.anim.frame2); dialog.show(); }
public void submit(final boolean flag, final String status, final int page) { String urlString = "http://112.126.72.250/ut_app/index.php?m=User&a=praise_list"; RequestParams params = new RequestParams(); params.put("user_id", userId); params.put("status", status); params.put("page", page + ""); waitDialog = new CustomProgressDialog(getActivity(), R.string.laoding_tips, R.anim.frame2); waitDialog.show(); // Utils.showToast(getActivity(), userId+":"+status); HttpUtils.post( urlString, params, new TextHttpResponseHandler() { @Override public void onSuccess(int arg0, Header[] arg1, String arg2) { waitDialog.dismiss(); Gson gson = new Gson(); if (status.equals("2")) { // 解析的是教练 FavoriateCoachBean fcb = gson.fromJson(arg2, FavoriateCoachBean.class); if (fcb.code.equals("1")) { listCoach = fcb.list; if (myAdapter == null) { myAdapter = new MyAdapter(listCoach); listView.setAdapter(myAdapter); myAdapter.notifyDataSetChanged(); } else { if (flag) { myAdapter.addAndRefreshListView(listCoach); // Utils.showToast(getActivity(), listCoach.size()+":"+page); if (listCoach.size() == 0) { AbToastUtil.showToast(getActivity(), "没有更多数据了..."); } } else { myAdapter.refreshListView(listCoach); } } } else { fl_content.removeAllViews(); iv.setBackgroundResource(R.drawable.page_icon_empty); iv.setVisibility(View.VISIBLE); tv.setText("暂无数据"); pb.setVisibility(View.GONE); fl_content.addView(v); Utils.showToast(getActivity(), fcb.info); } } } @Override public void onFailure(int arg0, Header[] arg1, String arg2, Throwable arg3) { if (waitDialog != null) { waitDialog.dismiss(); } fl_content.removeAllViews(); iv.setBackgroundResource(R.drawable.pagefailed_bg); iv.setVisibility(View.VISIBLE); tv.setText("网络连接异常,点击重试"); pb.setVisibility(View.GONE); fl_content.addView(v); tv.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { submit(false, "2", 0); } }); Utils.showToast(getActivity(), "网络连接异常"); } }); }