实例介绍
【实例截图】
【核心代码】
package com.wiz.ui.activity;
import com.wiz.ui.adapter.AdImageAdapter;
import com.wiz.ui.adapter.R;
import com.wiz.ui.view.PageControlView;
import android.content.Intent;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.LinearLayout;
import android.widget.TextView;
public class IndexActivity extends ParentActivity implements
View.OnClickListener {
private String[] adString;
private Gallery ad_image;
private TextView ad_text;
private LinearLayout bottom_left;
private LinearLayout bottom_right;
private LinearLayout center_layout;
Handler galleryHandler = new Handler() {
public void handleMessage(Message paramMessage) {
int i = 1 ((Integer) paramMessage.obj).intValue();
if (i < 4) {
IndexActivity.this.ad_image.setSelection(i);
} else {
IndexActivity.this.ad_image.setSelection(0);
}
}
};
private boolean isFirstCreate = false;
private Button login_btn;
AdapterView.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> paramAdapterView,
View paramView, int paramInt, long paramLong) {
IndexActivity.this.page_control.generatePageControl(paramInt);
IndexActivity.this.ad_text
.setText(IndexActivity.this.adString[paramInt]);
IndexActivity.this.galleryHandler.removeMessages(0);
IndexActivity.this.galleryHandler.sendMessageDelayed(
IndexActivity.this.galleryHandler.obtainMessage(0,
Integer.valueOf(paramInt)), 2000L);
}
public void onNothingSelected(AdapterView<?> paramAdapterView) {
}
};
View.OnLongClickListener onLongClickListener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View paramView) {
int i = paramView.getId();
int j = 0;
Intent localIntent = null;
IndexActivity.this.startAnimal(i);
switch (i) {
case R.id.register:
j = 0;
break;
case R.id.hospital:
j = 1;
break;
case R.id.more:
j = 2;
break;
case R.id.myservice:
j = 3;
break;
}
localIntent = new Intent(IndexActivity.this, MainActivity.class);
localIntent.putExtra("intent_to_main_id", j);
IndexActivity.this.begin(localIntent);
return false;
}
};
private PageControlView page_control;
private LinearLayout top_left;
private LinearLayout top_right;
private void begin(Intent paramIntent) {
new AsyncTask<String, Void, String>() {
@Override
protected String doInBackground(String... params) {
try {
Thread.sleep(500L);
return null;
} catch (InterruptedException localInterruptedException) {
localInterruptedException.printStackTrace();
}
return null;
}
};
IndexActivity.this.startActivity(paramIntent);
}
public void onClick(View paramView) {
int i = paramView.getId();
int j = 0;
Intent localIntent = null;
IndexActivity.this.startAnimal(i);
switch (i) {
case R.id.register:
j = 0;
break;
case R.id.hospital:
j = 1;
break;
case R.id.more:
j = 2;
break;
case R.id.myservice:
j = 3;
break;
}
localIntent = new Intent(IndexActivity.this, MainActivity.class);
localIntent.putExtra("intent_to_main_id", j);
IndexActivity.this.begin(localIntent);
}
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
this.isFirstCreate = true;
init(R.layout.p_index);
}
public boolean onKeyDown(int keyCode, KeyEvent paramKeyEvent) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
showConfirmDialog(R.string.logout_info);
break;
}
return false;
}
protected void onResume() {
super.onResume();
if (!this.isFirstCreate)
resumStartAnimal();
this.isFirstCreate = false;
}
public void resumStartAnimal() {
this.top_left.startAnimation(AnimationUtils.loadAnimation(this.context,
R.anim.anim_left_resume));
this.top_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_top_resume));
this.center_layout.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center_resume));
this.bottom_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_bottom_resume));
this.bottom_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_right_resume));
this.top_left.setEnabled(true);
this.top_right.setEnabled(true);
this.center_layout.setEnabled(true);
this.bottom_left.setEnabled(true);
this.bottom_right.setEnabled(true);
}
protected void setupData() {
this.adString = getResources().getStringArray(R.array.ad_title);
}
protected void setupView() {
this.ad_image = (Gallery) findViewById(R.id.ad_image);
this.ad_text = (TextView) findViewById(R.id.ad_text);
this.page_control = (PageControlView) findViewById(R.id.pageControlView);
this.login_btn = (Button) findViewById(R.id.login_btn);
this.top_left = (LinearLayout) findViewById(R.id.top_left);
this.top_right = (LinearLayout) findViewById(R.id.top_right);
this.center_layout = (LinearLayout) findViewById(R.id.center);
this.bottom_left = (LinearLayout) findViewById(R.id.bottom_left);
this.bottom_right = (LinearLayout) findViewById(R.id.bottom_right);
this.top_left.setOnClickListener(this);
this.top_right.setOnClickListener(this);
this.center_layout.setOnClickListener(this);
this.bottom_left.setOnClickListener(this);
this.bottom_right.setOnClickListener(this);
this.top_left.setOnLongClickListener(this.onLongClickListener);
this.top_right.setOnLongClickListener(this.onLongClickListener);
this.center_layout.setOnLongClickListener(this.onLongClickListener);
this.bottom_left.setOnLongClickListener(this.onLongClickListener);
this.bottom_right.setOnLongClickListener(this.onLongClickListener);
AdImageAdapter localAdImageAdapter = new AdImageAdapter(this.context);
this.ad_image.setAdapter(localAdImageAdapter);
this.ad_image.setOnItemSelectedListener(this.onItemSelectedListener);
this.page_control.count = 4;
this.ad_image.setSelection(0);
this.login_btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View paramView) {
// Intent localIntent = new Intent(IndexActivity.this,
// UserLoginActivity.class);
// localIntent.addFlags(67108864);
// IndexActivity.this.startActivity(localIntent);
}
});
}
public void startAnimal(int paramInt) {
this.top_left.setEnabled(false);
this.top_right.setEnabled(false);
this.center_layout.setEnabled(false);
this.bottom_left.setEnabled(false);
this.bottom_right.setEnabled(false);
switch (paramInt) {
case R.id.register:
this.top_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
this.top_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_top));
this.center_layout.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
this.bottom_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_bottom));
this.bottom_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_right));
break;
case R.id.hospital:
this.top_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_left));
this.top_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
this.center_layout.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
this.bottom_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_bottom));
this.bottom_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_right));
break;
case R.id.more:
this.top_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_left));
this.top_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_top));
this.center_layout.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
this.bottom_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_bottom));
this.bottom_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_right));
break;
case R.id.myservice:
this.top_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_left));
this.top_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_top));
this.center_layout.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
this.bottom_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
this.bottom_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_right));
break;
default:
this.top_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_left));
this.top_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_top));
this.center_layout.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
this.bottom_left.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_bottom));
this.bottom_right.startAnimation(AnimationUtils.loadAnimation(
this.context, R.anim.anim_center));
}
// switch (paramInt) {
// case 2131361895:
// case 2131361897:
// case 2131361899:
// case 2131361901:
// default:
// case 2131361894:
// case 2131361896:
// case 2131361898:
// case 2131361900:
// case 2131361902:
// }
// while (true) {
// return;
// continue;
// continue;
// continue;
// this.top_left.startAnimation(AnimationUtils.loadAnimation(
// this.context, 2130968580));
// this.top_right.startAnimation(AnimationUtils.loadAnimation(
// this.context, 2130968584));
// this.center_layout.startAnimation(AnimationUtils.loadAnimation(
// this.context, 2130968578));
// this.bottom_left.startAnimation(AnimationUtils.loadAnimation(
// this.context, 2130968576));
// this.bottom_right.startAnimation(AnimationUtils.loadAnimation(
// this.context, 2130968578));
// }
}
}
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论