a460670026 2016-04-17 02:46 采纳率: 100%
浏览 1384
已采纳

关于安卓中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条回答 默认 最新

  • Emiya_Zero 2016-04-17 03:04
    关注

    你注意是不是.9图,直接copy到AS中的.9图如果没有图片说明这周围
    4个黑色的线是认为.9图是错误的

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab