package edu.huang.redirect;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
public class RedirectActivity extends Activity {
Button button = null;
Button button1 = null;
Button button2 = null;
LinearLayout linearLayout = null;
Bundle saved = null;
boolean flag;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.saved = savedInstanceState;
button1 = (Button)findViewById(R.id.button1);
button2 = (Button)findViewById(R.id.button2);
linearLayout = (LinearLayout)findViewById(R.id.layout);
button = new Button(this);
button.setId(R.id.button2+1);
button.setText("add one button");
button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
// linearLayout.addView(button);
linearLayout.addView(button, 1);
final Animation shack = AnimationUtils.loadAnimation(this, R.anim.shake);
final Handler handler = new Handler(){
public void handleMessage(Message msg) {
if (msg.what==1) {
linearLayout.removeView(button);
}
}
};
button.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
button.startAnimation(shack);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
handler.sendEmptyMessage(1);
}
}, 1100);
return false;
}
});
// button.setOnLongClickListener(new View.OnLongClickListener() {
//
// public boolean onLongClick(View v) {
// ok();
// flag = true;
// return false;
// }
// });
// if (flag) {
// button.setOnClickListener(new View.OnClickListener() {
// public void onClick(View v) {
// linearLayout.removeView(button);
// }
// });
// }
}
//
//
// private void ok(){
// Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
// button.startAnimation(shake);
// linearLayout.removeView(button);
// }
// class ListenerAnimation implements AnimationListener{
//
// public void onAnimationEnd(Animation animation) {
// mContainer.post(new SwapViews(mPosition));
//
// animation = null;
// }
//
// public void onAnimationRepeat(Animation animation) {
// // TODO Auto-generated method stub
//
// }
//
// public void onAnimationStart(Animation animation) {
// // TODO Auto-generated method stub
//
// }
//
// }
}
没有合适的资源?快使用搜索试试~ 我知道了~
长按按钮,按钮出现抖动,之后将按钮删除
共32个文件
class:11个
png:6个
xml:5个
4星 · 超过85%的资源 需积分: 9 199 下载量 139 浏览量
2012-09-14
23:15:06
上传
评论 1
收藏 61KB ZIP 举报
温馨提示
为便于初学Android的童鞋学习,写的小例子上传上来,在写这个小例子的时候遇到了一些问题,如果你也写过类似的例子,并且也遇到过问题,可能下面的链接会对你有用http://blog.csdn.net/ddna/article/details/5451722
资源推荐
资源详情
资源评论
收起资源包目录
Redirect.zip (32个子文件)
Redirect
.project 844B
project.properties 360B
proguard.cfg 1KB
src
edu
huang
redirect
RedirectActivity.java 3KB
AndroidManifest.xml 738B
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 3KB
layout
main.xml 796B
anim
cycle.xml 150B
shake.xml 329B
values
strings.xml 272B
.settings
org.eclipse.jdt.core.prefs 177B
assets
gen
edu
huang
redirect
R.java 1KB
.classpath 364B
bin
resources.ap_ 12KB
Redirect.apk 17KB
classes
edu
huang
redirect
R$layout.class 394B
R$drawable.class 407B
R$attr.class 340B
RedirectActivity$2$1.class 815B
RedirectActivity$2.class 1KB
R$id.class 446B
R$anim.class 418B
R.class 577B
R$string.class 489B
RedirectActivity.class 2KB
RedirectActivity$1.class 976B
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
classes.dex 5KB
共 32 条
- 1
来到我身边
- 粉丝: 47
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页