a460670026
2016-04-17 02:46关于安卓中Handler的问题
我想让图片每一秒换一次
package com.example.handler;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private ImageView imageView;
private TextView textView;
private Handler handle=new Handler();
private int anInt[]={R.drawable.f1,R.drawable.f2,R.drawable.f3,R.drawable.f4};
private int index;
private MyRunnable myRunnable=new MyRunnable();
class MyRunnable implements Runnable{
@Override
public void run() {
index++;
index=index%4;
imageView.setImageResource(anInt[index]);
handle.postDelayed(myRunnable,1000);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView= (TextView) findViewById(R.id.tv);
imageView= (ImageView) findViewById(R.id.imageView);
handle.postDelayed(myRunnable,1000);
}
}
然后运行结果报错
Gradle Build:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
AAPT err(Facade for 1575739509): libpng error: Not a PNG file
AAPT err(Facade for 16692146): libpng error: Not a PNG file
Error:Execution failed for task ':app:mergeDebugResources'.
Some file crunching failed, see logs for details
Information:BUILD FAILED
Information:Total time: 3.414 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
求大神支招
- 点赞
- 回答
- 收藏
- 复制链接分享
4条回答
为你推荐
- 在线程中发送message,handler收到msg后再toast,仍然抛异常,请问如何解决?
- android-studio
- java
- android
- 1个回答
- 通过Handler实现Service和Activity的数据交互,与onbind返回Binder对象冲突,我该如何解决?
- android-studio
- android
- 2个回答
- 关于handler 信息接收 问题。。。。。
- android
- 0个回答
- android安卓开发 获得的Handler里的值怎么取出来
- android
- handler
- 10个回答
- android小白使用sqlite出现闪退问题
- android
- 3个回答