The first is the Jiaoyuzixunactivity.java code section:
package com.gaoxiaotong.ctone.jiaoyuzixun;import java.util.arraylist;import java.util.hashmap; import java.util.iterator;import java.util.list;import java.util.map;import Org.json.jsonarray;import org.json.jsonobject;import com.gaoxiaotong.ctone.entity.jiaoyuzixun_ viewpage_adapter;import com.gaoxiaotong.ctone.entity.jianzhizhaopinadapter;import Com.gaoxiaotong.ctone.jianzhizhaopin.jianzhizhaopinactivity;import com.gaoxiaotong.info.webserinfo;import com.gaoxiaotongctone.MainActivity;import com.gaoxiaotongctone.R;import android.app.Activity; import android.app.progressdialog;import android.content.intent;import android.os.asynctask; import android.os.bundle;import android.os.parcelable;import android.support.v4.view.pageradapter;import android.support.v4.view.viewpager;import Android.support.v4.view.viewpager.onpagechangelistener;import android.util.log;import android. View. keyevent;import android.view.view;import android.view.viewgroup.layoutparams;import android.view.animation.animationset;import android.view.animation.translateanimation;import android.widget.adapterviewflipper;import android.widget.horizontalscrollview;import Android.widget.imageview;import android.widget.linearlayout;import android.widget.listview;import android.widget.ProgressBar;import android.widget.RadioButton;import android.widget.RadioGroup; import android.widget.textview;import android.widget.radiogroup.oncheckedchangelistener;/** * horizontalscrollview and Viewpager linkage effect above for Horizontalscrollview, below for Viewpager **/public class jiaoyuzixunactivity extends activity implementsoncheckedchangelistener {private progressdialog dialog;private progressbar progressbar;private hashmap<integer, integer> hmap;private int pageindex;private boolean load_pagesize;private int thepage;/** * Set layout Display Properties */ Private layoutparams mlayoutparams = new linearlayout.layoutparams ( linearlayout.layoutparams.wrap_content,linearlayout.layoutparams.wrap_content);/** * set layout display target maximize properties */private layoutparams fflayoutparams = new linearlayout.layoutparams ( linearlayout.layoutparams.match_parent,linearlayout.layoutparams.match_parent);p rivate linearlayout loadinglayout;private textview texview_back;private radiogroup mradiogroup;private radiobutton mradiobutton1;private radiobutton mradiobutton2;private radiobutton Mradiobutton3;private radiobutton mradiobutton4;private radiobutton mradiobutton5;private RadioButton mRadioButton6;private ImageView mImageView;private float mcurrentcheckedradioleft;// the distance to the left of the currently selected radiobutton distance PRivate horizontalscrollview mhorizontalscrollview;// the horizontal scroll control above private viewpager The mviewpager; // control below the private arraylist<view> mviews;// is used to store the layout of the scroll below ( Layout_1,layout_2,layout_3) @Overridepublic void oncreate (bundle savedinstancestate) { Super.oncreate (savedinstancestate); Setcontentview (r.layout.title_bar_education); Inicontroller (); IniListener (); Inivariable (); mradiobutton1.setchecked (true); Mviewpager.setcurrentitem (1); mcurrentcheckedradioleft = getcurrentcheckedradioleft ();// return to Texview_back.setonclicklistener (New view.onclicklistener () {@Overridepublic void onclick (view v) {// todo auto-generated method stubintent intent = new intent (Jiaoyuzixunactivity.this,mainactivity.class); StartActivity (Intent); JiaoyuzixunActivity.this.finish ();}}); / Binding Postgraduate examination, special promotion and so on part}/** * asynctask asynchronous loading part of the Operation */public class mytasKjianzhi1 extendsasynctask<string, void, list<map<string, object>>> {private listview lvcont;private jianzhizhaopinadapter adapter;private int index;// determine if the adapter is empty part public mytaskjianzhi1 (listview lvcont, jianzhizhaopinadapter jzzpadapter) {super ();this.lvcont = lvcont;if (jzzpadapter == null) { Adapter = new jianzhizhaopinadapter (jiaoyuzixunactivity.this);} else {adapter = jzzpadapter;}} Download Cue box @overrideprotected void onpreexecute () {// TODO Auto-generated Method stubsuper.onpreexecute ();d ialog = new progressdialog (JiaoyuzixunActivity.this); Dialog.settitle ("hint");d ialog.setmessage ("Downloading now, please later ....");d ialog.show (); End of Operation section @overrideprotected void onpostexecute (list<map<string, object>> Result) {// todo auto-generated Method stubsuper.onpostexecute (Result);// bound to the postgraduate examination, the special promotion of this part string aa = ""; try {if (thepage == 1) {adapter.setdata (result); Lvcont.setadapter (adapter);} if (Result.size () == 0) {loadinglayout.setvisibility (View.gone);} Adapter.notifydatasetchanged ();} catch (exception e) {// todo: handle exceptione.getmessage (); E.printstacktrace ();} Dialog.dismiss ();} Get Data Manipulation section @overrideprotected list<map<string, object>> doinbackground (String ... params) {// TODO Auto-generated method stubList<Map<String, object>> list = new arraylist<map<string, object>> ();// link Network, Get JSON, parse data try {webserinfo wswebserinfo = new webserinfo (); Jsonarray data = new jsonarray ();if (pageindex == 0) {data = wswebserinfo.jobsbytype ("" +&nBsp Webserinfo.pagesize, "2", "" + thepage);} else if (pageindex == 1) {data = wswebserinfo.jobsbytype ("" + webserinfo.pagesize, "1", "" + thepage);} else if (pageindex == 2) {data = wswebserinfo.jobsbytype ("" + webserinfo.pagesize, "3", "" + thepage);} if (Data.length () < 10) {load_pagesize = false;} for (Int i = 0; i < data.length (); i++) {JSONObject Jsonobj = data.getjsonobject (i); Hashmap<string, object> map = new hashmap<string, object> ();// The iteration output JSON key is used as the map's Keyiterator<string> iterator = jsonobj.keys ();while ( Iterator.hasnext ()) {string key = iterator.next ();object value = Jsonobj.get (key); Map.put (Key, value);} if (thepage > 1) {adapter.additem (map);} List.add (map);}} catch (Exception e) {// todo: handle exception}return list;}} Private void inivariable () {// todo auto-generated method stubmviews = new ArrayList<View> (); Mviews.add (Getlayoutinflater (). Inflate (r.layout.layout_0, null)); Mviews.add (Getlayoutinflater (). Inflate (R.layout.layout_1, null)); Mviews.add (Getlayoutinflater (). Inflate ( R.layout.layout_2, null)); Mviews.add (Getlayoutinflater () inflate (r.layout.layout_3, null)); Mviews.add (Getlayoutinflater (). Inflate (R.layout.layout_4, null)); Mviews.add (Getlayoutinflater (). Inflate ( R.layout.layout_5, null)); Mviews.add (Getlayoutinflater () inflate (r.layout.layout_6, null)); Mviews.add (Getlayoutinflater (). Inflate (R.layout.layout_0, null)); Mviewpager.setadapter (new Jiaoyuzixun_viewpage_adapter (mviews));// set Viewpager adapter}/** * radiogroup Click CheckedChanged Listen */@Overridepublic void oncheckedchanged (radiogroup group, int checkedid) { Animationset _animationset = new animationset (TRUE); translateanimation _translateanimation; LOG.I ("ZJ", "checkedid=" + checkedid);if (CHECKEDID&NBSP;==&NBSP;R.ID.BTN1) {_ Translateanimation = new translateanimation (Mcurrentcheckedradioleft, getresources (). Getdimension (R.DIMEN.RDO1), 0f, 0f); _animationset.addanimation (_translateanimation); _ Animationset.setfillbefore (false); _animationset.setfillafter (true); _animationset.setduration (100); Mimageview.startanimation (_animationset);// start the animation toggle above the blue bar picture// mimageview.setlayoutparams (_ LAYOUTPARAMS1); Mviewpager.setcurrentitem (1);// let the viewpager below follow the horizontalscrollview switch} else if (CHECKEDID&NBSP;==&NBSP;R.ID.BTN2) {_translateanimation = new translateanimation ( Mcurrentcheckedradioleft, getresources (). GetdimensiOn (R.DIMEN.RDO2), 0f, 0f); _animationset.addanimation (_translateanimation); _ Animationset.setfillbefore (false); _animationset.setfillafter (true); _animationset.setduration (100); Mimageview.startanimation (_animationset); Mviewpager.setcurrentitem (2);} else if (CHECKEDID&NBSP;==&NBSP;R.ID.BTN3) {_TranslateAnimation = new Translateanimation (Mcurrentcheckedradioleft, getresources (). Getdimension (R.dimen.rdo3), 0f, 0f) ; _animationset.addanimation (_translateanimation); _animationset.setfillbefore (false); _animationset.setfillafter (true); _animationset.setduration (+); mimageview.startanimation (_animationset); Mviewpager.setcurrentitem (3);} else if (CHECKEDID&NBSP;==&NBSP;R.ID.BTN4) {_TranslateAnimation = new Translateanimation (Mcurrentcheckedradioleft, getresources (). Getdimension (R.dimen.rdo4), 0f, 0f) ; _animationset.addanimation (_translateanimation); _animationset.setfillbefore (false); _animationsEt.setfillafter (True); _animationset.setduration (+); mimageview.startanimation (_animationset); Mviewpager.setcurrentitem (4);} else if (CHECKEDID&NBSP;==&NBSP;R.ID.BTN5) {_TranslateAnimation = new Translateanimation (Mcurrentcheckedradioleft, getresources (). Getdimension (R.DIMEN.RDO5), 0f, 0f) ; _animationset.addanimation (_translateanimation); _animationset.setfillbefore (false); _animationset.setfillafter (true); _animationset.setduration (+); mimageview.startanimation (_animationset); Mviewpager.setcurrentitem (5);} else if (CHECKEDID&NBSP;==&NBSP;R.ID.BTN6) {_TranslateAnimation = new Translateanimation (Mcurrentcheckedradioleft, getresources (). Getdimension (R.dimen.rdo6), 0f, 0f) ; _animationset.addanimation (_translateanimation); _animationset.setfillbefore (false); _animationset.setfillafter (true); _animationset.setduration (+); mimageview.startanimation (_animationset); Mviewpager.setcurrentitem (6);} McurreNtcheckedradioleft = getcurrentcheckedradioleft ();// Update the distance to the left of the current blue bars Mhorizontalscrollview.smoothscrollto (int) mCurrentCheckedRadioLeft- (int) Getresources (). Getdimension (R.dimen.rdo2), 0);} /** * gets the distance to the left of the currently selected RadioButton Distance */private float getcurrentcheckedradioleft () {/ / todo auto-generated method stubif (mradiobutton1.ischecked ()) {return Getresources (). Getdimension (R.DIMEN.RDO1);} else if (mradiobutton2.ischecked ()) {return getresources (). Getdimension (R.dimen.rdo2 );} else if (mradiobutton3.ischecked ()) {return getresources (). Getdimension (R.dimen.rdo3 );} else if (mradiobutton4.ischecked ()) {return getresources (). Getdimension (R.dimen.rdo4 );} else if (mradiobutton5.ischecked ()) {return getresources (). Getdimension (R.dimen.rdo5 );} else if (mradiobutton6.ischecked ()) {returN getresources (). Getdimension (R.DIMEN.RDO6);} return 0f;} /** * Monitoring part Operation */private void inilistener () {// todo auto-generated method stubmradiogroup.setoncheckedchangelistener (this); Mviewpager.setonpagechangelistener (new mypageronpagechangelistener ());} Private void inicontroller () {// todo auto-generated method stubmradiogroup = (Radiogroup) findviewbyid (r.id.radiogroup);mradiobutton1 = (RadioButton) Findviewbyid (R.ID.BTN1);mradiobutton2 = (RadioButton) findviewbyid (R.ID.BTN2); MRadioButton3 = (RadioButton) findviewbyid (r.id.btn3);mradiobutton4 = (RadioButton) Findviewbyid (R.ID.BTN4);mradiobutton5 = (RadioButton) findviewbyid (R.ID.BTN5); mRadioButton6 = (RadioButton) findviewbyid (r.id.btn6);mimageview = (ImageView) findviewbyid ( R.ID.IMG1);texview_back = (TextView) &NBsp;findviewbyid (R.id.back_activity_button);mhorizontalscrollview = (HorizontalScrollView) Findviewbyid (R.id.horizontalscrollview);mviewpager = (Viewpager) findviewbyid (R.id.pager);} /** * viewpager Pagechangelistener (page change listener) */private class mypageronpagechangelistener implements onpagechangelistener {@Overridepublic void Onpagescrollstatechanged (int arg0) {// todo auto-generated method stub}@ Overridepublic void onpagescrolled (INT&NBSP;ARG0,&NBSP;FLOAT&NBSP;ARG1,&NBSP;INT&NBSP;ARG2) {// TODO Auto-generated method stub}/** * when sliding the Viewpager, Let the upper Horizontalscrollview automatically switch */@Overridepublic void onpageselected (int position) {// TODO Auto-generated method stubif (position == 0) { Mviewpager.setcurrentitem (1);} else if (position == 1) {mradiobutton1.performClick ();} else if (POSITION&NBSP;==&NBSP;2) {mradiobutton2.performclick ();} else if (position == 3) {mradiobutton3.performclick ();} else if (position == 4) {mradiobutton4.performclick ();} else if (position == 5) {mradiobutton5.performclick ();} else if (position == 6) {mradiobutton6.performclick ();} else if (position == 7) {mviewpager.setcurrentitem (6);}} back key @overridepublic boolean onkeydown (int keycode, keyevent event) {// TODO Auto-generated method stubif (keycode == keyevent.keycode_back && event.getrepeatcount () == 0) {intent intent = new intent (); Intent.setclass (Jiaoyuzixunactivity.this, mainactivity.class); JiaoyuzixunActivity.this.startActivity (Intent); Jiaoyuzixunactivity.thIs.finish ();} else {return false;} Return super.onkeydown (keycode, event);}}
Dimens.xml section, Control menu bar Display Item Effect:
<resources> <dimen name= "Padding_small" >8dp</dimen> <dimen name= "Padding_medium" >8dp</ dimen> <dimen name= "Padding_large" >16dp</dimen> <dimen name= "Rdo1" >0dp</dimen> <dim En name= "rdo2" >100dp</dimen> <dimen name= "Rdo3" >200dp</dimen> <dimen name= "Rdo4" >300DP&L t;/dimen> <dimen name= "Rdo5" >400dp</dimen> <dimen name= "Rdo6" >500dp</dimen></ Resources>
Excessive page Layout_0.xml section:
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "android:orientation=" vertical "android:layout_width=" match_parent "android:layout_height=" Match_parent " Android:background= "@android: Color/darker_gray" ></LinearLayout>
Show Page one of the Styles Layout_1.xml section:
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http// Schemas.android.com/apk/res/android " android:layout_width=" Match_parent " android:layout_height= "Match_parent" android:background= "@android: color/ Darker_gray " android:orientation=" vertical " > < Textview android:id= "@+id/textview_showmessages" android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" android:gravity = "Center" android:text= "A" android:textcolor= "#33b5e5" android:textsize= "240sp " /></LinearLayout>
:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/37/D3/wKiom1OxAlmyIyRxAADFtiFtP7E551.jpg "style=" float: none; "Title=" 360 mobile phone assistant 0630_14_10_01.png "alt=" Wkiom1oxalmyiyrxaadftiftp7e551.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/37/D2/wKioL1OxAiuCtT_gAAC3S7nITN4810.jpg "style=" float: none; "Title=" 360 mobile phone assistant 0630_14_10_02.png "alt=" Wkiol1oxaiuctt_gaac3s7nitn4810.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/37/D3/wKiom1OxAlqzYTXqAADau00ARWw949.jpg "style=" float: none; "Title=" 360 mobile phone assistant 0630_14_11_01.png "alt=" Wkiom1oxalqzytxqaadau00arww949.jpg "/>
This article is from the "Liangxiao Technology Center" blog, please be sure to keep this source http://liangxiao.blog.51cto.com/3626612/1432413