码迷,mamicode.com
首页 > 其他好文 > 详细

广告轮播

时间:2015-11-30 08:30:04      阅读:319      评论:0      收藏:0      [点我收藏+]

标签:

  1 package com.zxw.fragment;
  2 
  3 import java.io.BufferedReader;
  4 import java.io.IOException;
  5 import java.io.InputStream;
  6 import java.io.InputStreamReader;
  7 import java.io.UnsupportedEncodingException;
  8 import java.util.ArrayList;
  9 import java.util.List;
 10 
 11 import org.apache.http.HttpResponse;
 12 import org.apache.http.NameValuePair;
 13 import org.apache.http.client.ClientProtocolException;
 14 import org.apache.http.client.HttpClient;
 15 import org.apache.http.client.entity.UrlEncodedFormEntity;
 16 import org.apache.http.client.methods.HttpPost;
 17 import org.apache.http.impl.client.DefaultHttpClient;
 18 
 19 import cn.trinea.android.view.autoscrollviewpager.AutoScrollViewPager;
 20 
 21 import com.google.gson.Gson;
 22 import com.lidroid.xutils.HttpUtils;
 23 import com.lidroid.xutils.ViewUtils;
 24 import com.lidroid.xutils.exception.HttpException;
 25 import com.lidroid.xutils.http.RequestParams;
 26 import com.lidroid.xutils.http.ResponseInfo;
 27 import com.lidroid.xutils.http.callback.RequestCallBack;
 28 import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
 29 import com.lidroid.xutils.view.annotation.ViewInject;
 30 import com.nostra13.universalimageloader.core.DisplayImageOptions;
 31 import com.nostra13.universalimageloader.core.ImageLoader;
 32 import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
 33 import com.zxw.financial.PersonalActivity;
 34 import com.zxw.financial.ProdutActivity;
 35 import com.zxw.financial.R;
 36 import com.zxw.financial.ShenGouActivity;
 37 import com.zxw.model.home.AdBean;
 38 import com.zxw.model.home.Ad_Info;
 39 import com.zxw.model.home.DaiBean;
 40 import com.zxw.model.home.HeZuoBean;
 41 import com.zxw.model.home.HeZuo_InfoBean;
 42 import com.zxw.model.home.ProdutBean;
 43 import com.zxw.model.home.Produt_InfoBean;
 44 import com.zxw.model.home.TellBean;
 45 
 46 import android.app.AlertDialog;
 47 import android.app.AlertDialog.Builder;
 48 import android.content.DialogInterface;
 49 import android.content.Intent;
 50 import android.net.Uri;
 51 import android.os.Bundle;
 52 import android.os.Handler;
 53 import android.os.Message;
 54 import android.support.v4.app.Fragment;
 55 import android.support.v4.view.PagerAdapter;
 56 import android.support.v4.view.ViewPager.OnPageChangeListener;
 57 import android.util.Log;
 58 import android.view.LayoutInflater;
 59 import android.view.View;
 60 import android.view.View.OnClickListener;
 61 import android.view.ViewGroup;
 62 import android.widget.Button;
 63 import android.widget.CheckBox;
 64 import android.widget.EditText;
 65 import android.widget.ImageView;
 66 import android.widget.TextView;
 67 import android.widget.Toast;
 68 
 69 public class HomeFragment extends Fragment implements OnClickListener {
 70     @ViewInject(R.id.btn_home_daikuan)
 71     private Button btn_home_daikuan;
 72     @ViewInject(R.id.btn_home_fangkuan)
 73     private Button btn_home_fangkuan;
 74     @ViewInject(R.id.btn_dialog_dai_submit)
 75     private Button btn_dialog_dai_submit;
 76     @ViewInject(R.id.btn_dialog_fang_submit)
 77     private Button btn_dialog_fang_submit;
 78     private AlertDialog dialog;
 79     @ViewInject(R.id.tv_home_name)
 80     private TextView tv_home_name;
 81     @ViewInject(R.id.iv_home_fangdidai)
 82     private ImageView iv_home_fangdidai;
 83     @ViewInject(R.id.iv_home_jinrong)
 84     private ImageView iv_home_jinrong;
 85     @ViewInject(R.id.iv_home_yixin)
 86     private ImageView iv_home_yixin;
 87     @ViewInject(R.id.iv_home_chedidai)
 88     private ImageView iv_home_chedidai;
 89     @ViewInject(R.id.btn_home_personal)
 90     private Button btn_home_personal;
 91     @ViewInject(R.id.btn_home_shengou)
 92     private Button btn_home_shengou;
 93     private String user_Name;
 94     private int user_Id;
 95     ArrayList<HeZuo_InfoBean> list;
 96     @ViewInject(R.id.btn_home_phone)
 97     private Button btn_home_phone;
 98     private String tell;
 99     @ViewInject(R.id.et_dialog_dai_name)
100     private EditText et_dialog_dai_name;
101     @ViewInject(R.id.et_dialog_dai_phone)
102     private EditText et_dialog_dai_phone;
103     @ViewInject(R.id.et_dialog_dai_edu)
104     private EditText et_dialog_dai_edu;
105     @ViewInject(R.id.et_dialog_dai_year)
106     private EditText et_dialog_dai_year;
107     private String user_Id2;
108     @ViewInject(R.id.cb_dialog_true)
109     private CheckBox cb_dialog_true;
110     @ViewInject(R.id.et_dialog_fang_name)
111     private EditText et_dialog_fang_name;
112     @ViewInject(R.id.et_dialog_fang_phone)
113     private EditText et_dialog_fang_phone;
114     @ViewInject(R.id.et_dialog_fang_edu)
115     private EditText et_dialog_fang_edu;
116     @ViewInject(R.id.et_dialog_fang_year)
117     private EditText et_dialog_fang_year;
118     @ViewInject(R.id.cb_dialog_fang_true)
119     private CheckBox cb_dialog_fang_true;
120     @ViewInject(R.id.et_dialog_fang_shouyi)
121     private EditText et_dialog_fang_shouyi;
122     @ViewInject(R.id.view_pager_banner)
123     private AutoScrollViewPager view_pager_banner;
124     @ViewInject(R.id.position_get)
125     private TextView position_get;
126     @ViewInject(R.id.seachposition_one)
127     private ImageView seachposition_one;
128     @ViewInject(R.id.seachposition_two)
129     private ImageView seachposition_two;
130     @ViewInject(R.id.seachposition_three)
131     private ImageView seachposition_three;
132     private List<View> imagList;
133     ArrayList<Ad_Info> infos;
134     ImageLoader imageLoader = ImageLoader.getInstance();
135     @ViewInject(R.id.iv_home_tuijian)
136     private ImageView iv_home_tuijian;
137     private String produtName;
138     private String produtImage;
139     private int produtId;
140 
141     @Override
142     public View onCreateView(LayoutInflater inflater, ViewGroup container,
143             Bundle savedInstanceState) {
144         // TODO Auto-generated method stub
145         View view = View.inflate(getActivity(), R.layout.fragment_home, null);
146         ViewUtils.inject(this, view);
147 
148         /*
149          * 推荐产品
150          */
151         HttpUtils produtUtils = new HttpUtils();
152         RequestParams produtParams = new RequestParams();
153         produtParams.addBodyParameter("r", "index/procent_show");
154         produtUtils.send(HttpMethod.POST,
155                 "http://www.myphp888.com/index/index.php", produtParams,
156                 new RequestCallBack<String>() {
157 
158                     @Override
159                     public void onFailure(HttpException arg0, String arg1) {
160                         // TODO Auto-generated method stub
161 
162                     }
163 
164                     @Override
165                     public void onSuccess(ResponseInfo<String> arg0) {
166                         // TODO Auto-generated method stub
167                         String tellResult = arg0.result;
168                         Log.i("url", "urllllllllll" + tellResult);
169                         ProdutBean produtBean = gson.fromJson(tellResult,
170                                 ProdutBean.class);
171                         ArrayList<Produt_InfoBean> proList = produtBean
172                                 .getInfo();
173                         produtId = proList.get(0).getPro_id();
174                         Log.i("撒打算", "1产品Id:" + produtId);
175                         produtName = proList.get(0).getPro_name();
176                         produtImage = proList.get(0).getPro_image();
177                         imageLoader.displayImage(proList.get(0).getPro_image(),
178                                 iv_home_tuijian);
179                         tv_home_name.setText(proList.get(0).getPro_name());
180 
181                         tv_home_name.setOnClickListener(new OnClickListener() {
182 
183                             @Override
184                             public void onClick(View v) {
185                                 // TODO Auto-generated method stub
186                                 intent = new Intent(getActivity(),
187                                         ProdutActivity.class);
188                                 intent.putExtra("produtName", produtName);
189                                 intent.putExtra("produtImage", produtImage);
190                                 startActivity(intent);
191                             }
192                         });
193 
194                         btn_home_shengou
195                                 .setOnClickListener(new OnClickListener() {
196 
197                                     @Override
198                                     public void onClick(View v) {
199                                         // TODO Auto-generated method stub
200                                         intent = new Intent(getActivity(),
201                                                 ShenGouActivity.class);
202                                         Log.i("撒打算", "2产品Id:" + produtId);
203                                         intent.putExtra("produtId", produtId);
204                                         intent.putExtra("user_Id", user_Id2);
205                                         startActivity(intent);
206                                     }
207                                 });
208                     }
209                 });
210 
211         /*
212          * 设置广告轮播
213          */
214         view_pager_banner.setOnPageChangeListener(pagelistener);
215         HttpUtils httpUtils = new HttpUtils();
216         RequestParams params = new RequestParams();
217         params.addBodyParameter("r", "index/shuffling_figure");
218         httpUtils.send(HttpMethod.POST,
219                 "http://www.myphp888.com/index/index.php", params,
220                 new RequestCallBack<String>() {
221 
222                     @Override
223                     public void onFailure(HttpException arg0, String arg1) {
224                         // TODO Auto-generated method stub
225 
226                     }
227 
228                     @Override
229                     public void onSuccess(ResponseInfo<String> arg0) {
230                         // TODO Auto-generated method stub
231                         String tellResult = arg0.result;
232                         Log.i("url", "urllllllllll" + tellResult);
233                         AdBean adBean = gson.fromJson(tellResult, AdBean.class);
234                         infos = adBean.getInfo();
235 
236                         imageLoader.displayImage(infos.get(0).getUrl(), imag);
237                         imageLoader.displayImage(infos.get(1).getUrl(), imag1);
238                         imageLoader.displayImage(infos.get(2).getUrl(), imag2);
239                     }
240                 });
241 
242         getimageShow();
243         view_pager_banner.setAdapter(pageadp);
244         view_pager_banner.startAutoScroll(4000);
245         view_pager_banner.setCycle(true);
246         view_pager_banner.setInterval(4000);
247         view_pager_banner.setStopScrollWhenTouch(true);
248         view_pager_banner.setDirection(AutoScrollViewPager.RIGHT);
249         view_pager_banner
250                 .setSlideBorderMode(AutoScrollViewPager.SLIDE_BORDER_MODE_CYCLE);
251 
252         gson = new Gson();
253 
254         /*
255          * 合作机构
256          */
257         new Thread() {
258 
259             public void run() {
260 
261                 String httpUrl = "http://www.myphp888.com/index/index.php?r=index/partners";
262                 HttpPost post = new HttpPost(httpUrl);
263                 List<NameValuePair> pList = new ArrayList<NameValuePair>();
264                 // 得到HttpClient实例
265                 HttpClient client = new DefaultHttpClient();
266 
267                 UrlEncodedFormEntity entity;
268                 try {
269                     entity = new UrlEncodedFormEntity(pList, "UTF-8");
270 
271                     post.setHeader("Content-Typr",
272                             "application/x-www-form-urlencoded;charset=utf-8");
273 
274                     post.setEntity(entity);
275 
276                     HttpResponse response = client.execute(post);
277 
278                     Log.i("TAG", response.getStatusLine().getStatusCode()
279                             + "-------------");
280 
281                     if (response.getStatusLine().getStatusCode() == 200) {
282 
283                         // 得到输入流
284                         InputStream stream = response.getEntity().getContent();
285                         // 实例化BufferedReader
286                         BufferedReader bf = new BufferedReader(
287                                 new InputStreamReader(stream));
288                         // 实例化StringBuffer
289                         StringBuffer sb = new StringBuffer();
290                         String str = null;
291                         while ((str = bf.readLine()) != null) {
292                             sb.append(str);
293                         }
294                         gson = new Gson();
295                         HeZuoBean heZuoBean = gson.fromJson(sb.toString(),
296                                 HeZuoBean.class);
297                         ArrayList<HeZuo_InfoBean> hezuoList = heZuoBean
298                                 .getInfo();
299                         Log.i("TAG", sb.toString() + "-------");
300 
301                         Message message = handler.obtainMessage(1, hezuoList);
302                         handler.sendMessage(message);
303                         stream.close();
304                     }
305                 } catch (UnsupportedEncodingException e) {
306                     // TODO Auto-generated catch block
307                     e.printStackTrace();
308                 } catch (ClientProtocolException e) {
309                     // TODO Auto-generated catch block
310                     e.printStackTrace();
311                 } catch (IOException e) {
312                     // TODO Auto-generated catch block
313                     e.printStackTrace();
314                 }
315 
316             }
317         }.start();
318         /*
319          * 首页电话号码
320          */
321         HttpUtils tellUtils = new HttpUtils();
322         RequestParams tellparams = new RequestParams();
323         tellparams.addBodyParameter("r", "index/tell");
324         tellUtils.send(HttpMethod.POST,
325                 "http://www.myphp888.com/index/index.php", tellparams,
326                 new RequestCallBack<String>() {
327 
328                     @Override
329                     public void onFailure(HttpException arg0, String arg1) {
330                         // TODO Auto-generated method stub
331 
332                     }
333 
334                     @Override
335                     public void onSuccess(ResponseInfo<String> arg0) {
336                         // TODO Auto-generated method stub
337                         String tellResult = arg0.result;
338                         TellBean tellBean = gson.fromJson(tellResult,
339                                 TellBean.class);
340                         tell = tellBean.getInfo().get(0).getPhone();
341                     }
342                 });
343 
344         /*
345          * 监听事件
346          */
347         btn_home_daikuan.setOnClickListener(this);
348         btn_home_fangkuan.setOnClickListener(this);
349         tv_home_name.setOnClickListener(this);
350         iv_home_fangdidai.setOnClickListener(this);
351         iv_home_jinrong.setOnClickListener(this);
352         iv_home_yixin.setOnClickListener(this);
353         iv_home_chedidai.setOnClickListener(this);
354         btn_home_personal.setOnClickListener(this);
355         btn_home_shengou.setOnClickListener(this);
356         btn_home_phone.setOnClickListener(this);
357         /*
358          * 传递数据
359          */
360         Bundle bundle = getArguments();
361         user_Id = bundle.getInt("user_id");
362         user_Name = bundle.getString("user_name");
363         user_Id2 = user_Id + "";
364         return view;
365     }
366 
367     /*
368      * (non-Javadoc)
369      * 
370      * @see android.view.View.OnClickListener#onClick(android.view.View) 点击时间的设置
371      */
372     @Override
373     public void onClick(View v) {
374         // TODO Auto-generated method stub
375         switch (v.getId()) {
376         // 我要贷款对话框
377         case R.id.btn_home_daikuan:
378 
379             View daiView = View.inflate(getActivity(), R.layout.dialog_daikuan,
380                     null);
381             getDialog(daiView);
382             ViewUtils.inject(this, daiView);
383 
384             btn_dialog_dai_submit.setOnClickListener(this);
385 
386             break;
387         // 我要放款对话框
388         case R.id.btn_home_fangkuan:
389             View fangView = View.inflate(getActivity(),
390                     R.layout.dialog_fangkuan, null);
391             getDialog(fangView);
392             ViewUtils.inject(this, fangView);
393 
394             btn_dialog_fang_submit.setOnClickListener(this);
395             break;
396         // 贷款对话框提交按钮
397         case R.id.btn_dialog_dai_submit:
398             diaName = et_dialog_dai_name.getText().toString();
399 
400             diaPhone = et_dialog_dai_phone.getText().toString();
401             diaEdu = et_dialog_dai_edu.getText().toString();
402             diaYear = et_dialog_dai_year.getText().toString();
403             daiCheck = cb_dialog_true.isChecked();
404             HttpUtils httpUtils = new HttpUtils();
405             RequestParams params = new RequestParams();
406             params.addBodyParameter("r", "Member/loan");
407             params.addBodyParameter("user_id", user_Id2);
408             params.addBodyParameter("name", diaName);
409             params.addBodyParameter("phone", diaPhone);
410             params.addBodyParameter("money", diaEdu);
411             params.addBodyParameter("deadline", diaYear);
412             params.addBodyParameter("is_agree", daiCheck + "");
413             httpUtils.send(HttpMethod.POST,
414                     "http://www.myphp888.com/index/index.php", params,
415                     new RequestCallBack<String>() {
416 
417                         @Override
418                         public void onFailure(HttpException arg0, String arg1) {
419                             // TODO Auto-generated method stub
420 
421                         }
422 
423                         @Override
424                         public void onSuccess(ResponseInfo<String> arg0) {
425                             // TODO Auto-generated method stub
426                             String tellResult = arg0.result;
427                             DaiBean daiBean = gson.fromJson(tellResult,
428                                     DaiBean.class);
429                             daiResult = daiBean.getData();
430                             Toast.makeText(getActivity(), daiResult, 0).show();
431                         }
432                     });
433             dialog.dismiss();
434             dialog.cancel();
435             break;
436         // 放款对话框提交按钮
437         case R.id.btn_dialog_fang_submit:
438             String fangResult;
439             String fangYear;
440             String fangEdu;
441             String fangPhone;
442             String fangName;
443             String fangRate;
444             boolean fangCheck;
445             fangName = et_dialog_fang_name.getText().toString();
446             fangRate = et_dialog_fang_shouyi.getText().toString();
447             fangPhone = et_dialog_fang_phone.getText().toString();
448             fangEdu = et_dialog_fang_edu.getText().toString();
449             fangYear = et_dialog_fang_year.getText().toString();
450             fangCheck = cb_dialog_fang_true.isChecked();
451             HttpUtils fangUtils = new HttpUtils();
452             RequestParams fangParams = new RequestParams();
453             fangParams.addBodyParameter("r", "Member/lending");
454             fangParams.addBodyParameter("uid", user_Id2);
455             fangParams.addBodyParameter("u_name", fangName);
456             fangParams.addBodyParameter("phone", fangPhone);
457             fangParams.addBodyParameter("money", fangEdu);
458             fangParams.addBodyParameter("put_time", fangYear);
459             fangParams.addBodyParameter("yield_rate", fangRate);
460             fangParams.addBodyParameter("is_agree", fangCheck + "");
461             fangUtils.send(HttpMethod.POST,
462                     "http://www.myphp888.com/index/index.php", fangParams,
463                     new RequestCallBack<String>() {
464 
465                         @Override
466                         public void onFailure(HttpException arg0, String arg1) {
467                             // TODO Auto-generated method stub
468 
469                         }
470 
471                         @Override
472                         public void onSuccess(ResponseInfo<String> arg0) {
473                             // TODO Auto-generated method stub
474                             String tellResult = arg0.result;
475                             DaiBean daiBean = gson.fromJson(tellResult,
476                                     DaiBean.class);
477                             daiResult = daiBean.getData();
478                             Toast.makeText(getActivity(), daiResult, 0).show();
479                         }
480                     });
481             dialog.dismiss();
482             break;
483         // case R.id.tv_home_name:
484         // startActivity(new Intent(getActivity(), ProdutActivity.class));
485         // break;
486         case R.id.iv_home_fangdidai:
487 
488             intent = new Intent(getActivity(), HeZuoActivity.class);
489             intent.putExtra("mechanism_name", mechanism_name);
490             startActivity(intent);
491             break;
492         case R.id.iv_home_jinrong:
493             startActivity(new Intent(getActivity(), HeZuoActivity.class));
494             break;
495         case R.id.iv_home_yixin:
496             startActivity(new Intent(getActivity(), HeZuoActivity.class));
497             break;
498         case R.id.iv_home_chedidai:
499             startActivity(new Intent(getActivity(), HeZuoActivity.class));
500             break;
501         // 个人中心的监听
502         case R.id.btn_home_personal:
503             intent = new Intent(getActivity(), PersonalActivity.class);
504             intent.putExtra("user_id", user_Id);
505             intent.putExtra("user_name", user_Name);
506             startActivity(intent);
507             break;
508         // case R.id.btn_home_shengou:
509         // startActivity(new Intent(getActivity(), ShenGouActivity.class));
510         // break;
511         // 电话的监听
512         case R.id.btn_home_phone:
513             builder = new Builder(getActivity());
514             builder.setMessage(tell);
515             builder.setNegativeButton("取消",
516                     new android.content.DialogInterface.OnClickListener() {
517 
518                         @Override
519                         public void onClick(DialogInterface dialog, int which) {
520                             // TODO Auto-generated method stub
521                             builder.create().cancel();
522                         }
523                     });
524             builder.setPositiveButton("一键拨打",
525                     new android.content.DialogInterface.OnClickListener() {
526 
527                         @Override
528                         public void onClick(DialogInterface dialog, int which) {
529                             // TODO Auto-generated method stub
530                             String phoneNum = tell;
531 
532                             Intent intent = new Intent(Intent.ACTION_CALL, Uri
533                                     .parse("tel:" + phoneNum));
534 
535                             startActivity(intent);
536                         }
537                     });
538             builder.show();
539             break;
540         default:
541             break;
542         }
543     }
544 
545     /*
546      * 贷款和放款对话框的调用方法
547      */
548     private void getDialog(View dialogView) {
549         builder = new Builder(getActivity());
550         dialog = builder.create();
551         builder.setView(dialogView);
552         ViewUtils.inject(this, dialogView);
553         builder.show();
554 
555     }
556 
557     /*
558      * 处理次线程合作机构
559      */
560     Handler handler = new Handler() {
561         public void handleMessage(android.os.Message msg) {
562             switch (msg.what) {
563             case 1:
564                 list = (ArrayList<HeZuo_InfoBean>) msg.obj;
565                 for (int i = 0; i < list.size(); i++) {
566                     DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
567                             .displayer(new RoundedBitmapDisplayer(180)).build();
568                     if (i == 0) {
569 
570                         mechanism_name = list.get(i).getMechanism_name();
571                         imageLoader.displayImage(list.get(i)
572                                 .getMechanism_logo(), iv_home_fangdidai,
573                                 displayImageOptions);
574                     } else if (i == 1) {
575                         mechanism_name = list.get(i).getMechanism_name();
576                         imageLoader.displayImage(list.get(i)
577                                 .getMechanism_logo(), iv_home_jinrong,
578                                 displayImageOptions);
579                     } else if (i == 2) {
580                         mechanism_name = list.get(i).getMechanism_name();
581                         imageLoader.displayImage(list.get(i)
582                                 .getMechanism_logo(), iv_home_yixin,
583                                 displayImageOptions);
584                     } else if (i == 3) {
585                         mechanism_name = list.get(i).getMechanism_name();
586                         imageLoader.displayImage(list.get(i)
587                                 .getMechanism_logo(), iv_home_chedidai,
588                                 displayImageOptions);
589                     }
590                 }
591                 break;
592 
593             default:
594                 break;
595             }
596 
597         };
598     };
599 
600     /*
601      * 广告轮播页的页面
602      */
603     private void getimageShow() {
604         imagList = new ArrayList<View>();
605         View imagV = LayoutInflater.from(getActivity()).inflate(
606                 R.layout.imagelist, null);
607         imag = (ImageView) imagV.findViewById(R.id.page_imag);
608 
609         View imagV1 = LayoutInflater.from(getActivity()).inflate(
610                 R.layout.imagelist1, null);
611         imag1 = (ImageView) imagV1.findViewById(R.id.page_imag1);
612 
613         View imagV2 = LayoutInflater.from(getActivity()).inflate(
614                 R.layout.imagelist2, null);
615         imag2 = (ImageView) imagV2.findViewById(R.id.page_imag2);
616 
617         imagList.add(imagV);
618         imagList.add(imagV1);
619         imagList.add(imagV2);
620 
621         Log.i("url", "urllllllldddddddddddddlll" + imagList.size());
622     }
623 
624     // 加上自动轮播
625     PagerAdapter pageadp = new PagerAdapter() {
626 
627         @Override
628         public boolean isViewFromObject(View arg0, Object arg1) {
629             // TODO Auto-generated method stub
630             return arg0 == arg1;
631         }
632 
633         @Override
634         public int getCount() {
635             // TODO Auto-generated method stub
636             return imagList.size();
637         }
638 
639         @Override
640         public void destroyItem(ViewGroup container, int position, Object object) {
641             // super.destroyItem(container, position, object);
642             container.removeView(imagList.get(position));
643         }
644 
645         @Override
646         public Object instantiateItem(ViewGroup container, int position) {
647             // TODO Auto-generated method stub
648             View image = imagList.get(position);
649             container.addView(image);
650             return image;
651         }
652 
653     };
654     /*
655      * 轮播的事件监听
656      */
657     OnPageChangeListener pagelistener = new OnPageChangeListener() {
658 
659         @Override
660         public void onPageSelected(int arg0) {
661             // TODO Auto-generated method stub
662             hideimage();
663             switch (arg0) {
664             case 0:
665                 seachposition_one
666                         .setBackgroundResource(R.drawable.im_input_phiz_page_indicator_sel);
667                 break;
668             case 1:
669                 seachposition_two
670                         .setBackgroundResource(R.drawable.im_input_phiz_page_indicator_sel);
671                 break;
672             case 2:
673                 seachposition_three
674                         .setBackgroundResource(R.drawable.im_input_phiz_page_indicator_sel);
675                 break;
676 
677             default:
678                 break;
679             }
680         }
681 
682         @Override
683         public void onPageScrolled(int arg0, float arg1, int arg2) {
684             // TODO Auto-generated method stub
685         }
686 
687         @Override
688         public void onPageScrollStateChanged(int arg0) {
689             // TODO Auto-generated method stub
690         }
691     };
692 
693     // 隐藏所有image
694     protected void hideimage() {
695         // TODO Auto-generated method stub
696         seachposition_one
697                 .setBackgroundResource(R.drawable.im_input_phiz_page_indicator_nor);
698         seachposition_two
699                 .setBackgroundResource(R.drawable.im_input_phiz_page_indicator_nor);
700         seachposition_three
701                 .setBackgroundResource(R.drawable.im_input_phiz_page_indicator_nor);
702     }
703 
704     private Intent intent;
705     private String mechanism_name;
706     private Gson gson;
707     private AlertDialog.Builder builder;
708     private String daiResult;
709     private String diaYear;
710     private String diaEdu;
711     private String diaPhone;
712     private String diaName;
713     private boolean daiCheck;
714     private ImageView imag;
715     private ImageView imag1;
716     private ImageView imag2;
717 }

 

广告轮播

标签:

原文地址:http://www.cnblogs.com/zxwisfdlkjglkf/p/5006199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!