程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> android-關於安卓中Handler的問題

android-關於安卓中Handler的問題

編輯:編程解疑
關於安卓中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

求大神支招

最佳回答:


你注意是不是.9圖,直接copy到AS中的.9圖如果沒有圖片說明這周圍
4個黑色的線是認為.9圖是錯誤的

a460670026
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved