android问题,求助
自定义的view。。
public class MyView extends View {
private Context context ;
private Bitmap showBmp ;
private Matrix matrix ;
private Camera camera ;
public int deltaX ;
private int centerX , centerY ;
public MyView(Context context){
super(context);
this.context = context ;
initData();
}
//自定义view组件
public MyView(Context context,AttributeSet att) {
super(context,att);
this.context = context ;
initData();
}
private void initData(){
showBmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.coinface);
centerX = showBmp.getWidth()/2 ;
centerY = showBmp.getHeight()/2 ;
matrix = new Matrix();
camera = new Camera();
// timer=new Timer();
}
//布局位置
@Override
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
}
//重新绘画
protected void onDraw(Canvas canvas) {
camera.save();
//绕X轴旋转
camera.rotateX(deltaX);
camera.getMatrix(matrix);
camera.restore();
//translate平移,pre前
matrix.preTranslate(-this.centerX, -this.centerY);
//post是后乘,当前的矩阵乘以参数给出的矩阵
matrix.postTranslate(this.centerX, this.centerY);
canvas.drawBitmap(showBmp, matrix, null);
}
}
activity里:
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
//MIN_DISTANCE滑动的最短距离
if(e1.getY()-e2.getY()>MIN_DISTANCE){
Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
switch(msg.what){
case 1:
myView.deltaX+=95.0f;
break;
}
myView.invalidate();
}
};
//定时器
timer.schedule(new TimerTask() {
@Override
public void run() {
Message message = new Message();
message.what = 1;
handler.sendMessage(message);
}
}, 0,1);
Toast.makeText(this, "滑动了", Toast.LENGTH_LONG).show();
return true;
}else{
return false;
}
}
是不是handler写错了,滑动了没更新UI。。。toast显示滑动了。。
相关推荐
安卓项目实战视频源码
安卓项目实网盘链接 包含一系列实战项目 视频 以及源码
安卓4.0源码编译问题
昨天想下载android4.0.4的源代码,结果一执行repo sync就遇到了下面的错误: Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner self.run() File "/usr/lib/python2.6/threading.py", line 484, in run self.__target(*self.__args, **self.__kwargs) File "/home/android/.repo/repo/subcmds/sync.py", line 200, in _FetchHelper clone_bundle=not opt.no_clone_bundle) File "/home/android/.repo/repo/project.py", line 978, in Sync_NetworkHalf and self._ApplyCloneBundle(initial=is_new, quiet=quiet): File "/home/android/.repo/repo/project.py", line 1519, in _ApplyCloneBundle exist_dst = self._FetchBundle(bundle_url, bundle_tmp, bundle_dst, quiet) File "/home/android/.repo/repo/project.py", line 1583, in _FetchBundle raise DownloadError('%s: %s ' % (req.get_host(), str(e)))
MyCode:救救我安卓应用
我的代码 此应用程序用于拯救在旅行中遇到问题的人 Save Me Android 应用程序 (Aditi Panday)
基于Android的紧急求助软件的设计与实现.pdf
基于Android的紧急求助软件的设计与实现.pdf
安卓微积分计算器
原作者:丶熊孩子的学霸室友 可以计算各种微分积分极限问题,实在无法计算还可以联网


