我想显示几个图像,并在每个图像之间添加延迟.我这样做并且代码中没有错误但由于某种原因应用程序崩溃了.
Bitmap bitmap = BitmapFactory.decodeFile(imageIn);
ImageView myImageView = (ImageView)findViewById(R.id.imageview);
myImageView.setImageBitmap(bitmap);
// Those are the only 2 lines I used to make my handler
Handler handlerTimer = new Handler();
handlerTimer.postDelayed((Runnable) this, 20000);
Run Code Online (Sandbox Code Playgroud) 我正在尝试从我的SD卡读取图像,但我不确定我是否做得对.需要一些帮助
这是我阅读它的代码:
String imageInSD = "/sdcard/Hanud/" + c.getString(1) + ".PNG";
Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
ImageView myImageView = (ImageView)findViewById(R.id.imageview);
myImageView.setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud)
这是我的主要文件:
<?xml version="1.0" encoding="utf-8"?>
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- <ImageView
android:id="@+id/image"
android:scaleType="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>-->
<ImageView
android:id="@+id/imageview"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
/>
<TextView
android:id="@+id/myNameText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</WebView>
Run Code Online (Sandbox Code Playgroud) 我试图使用加速度计制作速度表但由于某种原因代码崩溃可以有人请告诉我有什么问题以及如何解决它谢谢你
这是logcat中的红色部分:
05-14 13:03:55.826: INFO/ActivityManager(91): Start proc com.hanud.speedo for activity com.hanud.speedo/.speedometer: pid=2052 uid=10127 gids={}
05-14 13:03:56.806: DEBUG/AndroidRuntime(2052): Shutting down VM
05-14 13:03:56.806: WARN/dalvikvm(2052): threadid=1: thread exiting with uncaught exception (group=0x400207f0)
05-14 13:03:56.986: ERROR/AndroidRuntime(2052): FATAL EXCEPTION: main
05-14 13:03:56.986: ERROR/AndroidRuntime(2052): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.hanud.speedo/com.hanud.speedo.speedometer}: java.lang.ClassNotFoundException: com.hanud.speedo.speedometer in loader dalvik.system.PathClassLoader[/data/app/com.hanud.speedo-2.apk]
05-14 13:03:56.986: ERROR/AndroidRuntime(2052): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-14 13:03:56.986: ERROR/AndroidRuntime(2052): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-14 13:03:56.986: ERROR/AndroidRuntime(2052): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-14 13:03:56.986: ERROR/AndroidRuntime(2052): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-14 13:03:56.986: ERROR/AndroidRuntime(2052): at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 13:03:56.986: ERROR/AndroidRuntime(2052): at android.os.Looper.loop(Looper.java:123) …Run Code Online (Sandbox Code Playgroud) 大家好,我对这段代码有疑问.我正试图让图像淡入淡出.这是日食错误:
The method loadAnimation(Context, int) in the type AnimationUtils is not applicable for the arguments (new Runnable(){}, int)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
Handler timerHandler = new Handler();
{
Runnable loadImg2 = new Runnable() {
public void run() {
DisplayTitle(gCursor);
Bitmap bitmap2 = BitmapFactory.decodeFile(sdcard/image.jpg);
myImageView=(ImageView)findViewById(R.id.imageview1);
(ImageView)findViewById(R.id.myImageView);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein);
myImageView.startAnimation(myFadeInAnimation);
myImageView.setImageBitmap(bitmap2);
timerHandler.postDelayed(clearImg, 55000);//55000);
");
}
};
Run Code Online (Sandbox Code Playgroud)