这是我的错误日志,请帮忙?
我是安卓新手,这是我的第一个应用
package gaurav.rapp.swamiji;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ViewSwitcher.ViewFactory;
public class BeWithSwamijiActivity extends Activity implements ViewFactory {
Integer pics[]={R.drawable.img1,R.drawable.img2,R.drawable.img3,R.drawable.img4,R.drawable.img5,R.drawable.img6,R.drawable.img7,R.drawable.img8,R.drawable.img9,R.drawable.img10,R.drawable.img11,R.drawable.img12,R.drawable.img13,R.drawable.img14,R.drawable.img15,R.drawable.img16,R.drawable.img17};
ImageSwitcher iSwitcher;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
iSwitcher = (ImageSwitcher) findViewById(R.id.ImageSwitcher01);
iSwitcher.setFactory(this);
iSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_in));
iSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_out));
Gallery gallery = (Gallery) findViewById(R.id.Gallery01);
gallery.setAdapter(new ImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
iSwitcher.setImageResource(pics[arg2]);
}
});
}
public class ImageAdapter extends BaseAdapter {
private Context ctx;
public ImageAdapter(Context c) {
ctx = c;
}
@Override
public int getCount() {
return pics.length;
}
@Override
public Object getItem(int arg0) {
return arg0;
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView iView = new ImageView(ctx);
iView.setImageResource(pics[arg0]);
iView.setScaleType(ImageView.ScaleType.FIT_XY);
iView.setLayoutParams(new Gallery.LayoutParams(150, 150));
return iView;
}
}
@Override
public View makeView() {
ImageView iView=new ImageView(this);
iView.setScaleType(ImageView.ScaleType.FIT_CENTER);
iView.setLayoutParams(new ImageSwitcher.LayoutParams(
LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
iView.setBackgroundColor(0xFF000000);
return iView;
}
}
日志
05-13 21:58:39.107: I/Process(397): Sending signal. PID: 397 SIG: 9
05-13 21:58:45.517: D/dalvikvm(409): GC_FOR_ALLOC freed 43K, 4% free 6362K/6595K, paused 75ms
05-13 21:58:45.587: I/dalvikvm-heap(409): Grow heap (frag case) to 10.624MB for 4566704-byte allocation
05-13 21:58:45.697: D/dalvikvm(409): GC_FOR_ALLOC freed 1K, 3% free 10820K/11079K, paused 86ms
05-13 21:58:45.887: D/dalvikvm(409): GC_CONCURRENT freed <1K, 3% free 10820K/11079K, paused 25ms+3ms
05-13 21:58:46.427: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 3% free 10820K/11079K, paused 112ms
05-13 21:58:46.547: I/dalvikvm-heap(409): Grow heap (frag case) to 18.362MB for 8114772-byte allocation
05-13 21:58:46.839: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 2% free 18745K/19015K, paused 72ms
05-13 21:58:47.057: D/dalvikvm(409): GC_CONCURRENT freed 0K, 2% free 18745K/19015K, paused 4ms+16ms
05-13 21:58:47.680: D/dalvikvm(409): GC_FOR_ALLOC freed 5051K, 26% free 15340K/20679K, paused 72ms
05-13 21:58:47.889: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 21% free 16537K/20679K, paused 71ms
05-13 21:58:47.889: I/dalvikvm-heap(409): Grow heap (frag case) to 18.284MB for 2179600-byte allocation
05-13 21:58:48.037: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 10% free 18666K/20679K, paused 75ms
05-13 21:58:48.307: D/dalvikvm(409): GC_CONCURRENT freed 0K, 10% free 18666K/20679K, paused 5ms+3ms
05-13 21:58:48.511: D/dalvikvm(409): GC_FOR_ALLOC freed 1197K, 11% free 18425K/20679K, paused 73ms
05-13 21:58:48.530: I/dalvikvm-heap(409): Grow heap (frag case) to 19.705MB for 1735988-byte allocation
05-13 21:58:48.681: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 11% free 20120K/22407K, paused 76ms
05-13 21:59:09.187: D/dalvikvm(409): GC_FOR_ALLOC freed 961K, 13% free 19660K/22407K, paused 75ms
05-13 21:59:11.737: D/dalvikvm(409): GC_FOR_ALLOC freed 678K, 10% free 20385K/22407K, paused 143ms
05-13 21:59:11.797: I/dalvikvm-heap(409): Grow heap (frag case) to 24.518MB for 4776976-byte allocation
05-13 21:59:11.971: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 8% free 25049K/27079K, paused 85ms
05-13 21:59:12.117: D/dalvikvm(409): GC_CONCURRENT freed <1K, 8% free 25049K/27079K, paused 4ms+3ms
05-13 21:59:12.327: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 8% free 25049K/27079K, paused 93ms
05-13 21:59:12.437: I/dalvikvm-heap(409): Grow heap (frag case) to 32.619MB for 8494048-byte allocation
05-13 21:59:12.589: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 6% free 33344K/35399K, paused 82ms
05-13 21:59:12.877: D/dalvikvm(409): GC_CONCURRENT freed 0K, 6% free 33345K/35399K, paused 5ms+4ms
05-13 21:59:29.208: D/dalvikvm(409): GC_FOR_ALLOC freed 4862K, 17% free 29383K/35399K, paused 84ms
05-13 21:59:31.130: D/dalvikvm(409): GC_FOR_ALLOC freed 353K, 13% free 30855K/35399K, paused 84ms
05-13 21:59:31.137: I/dalvikvm-heap(409): Grow heap (frag case) to 32.266MB for 2179600-byte allocation
05-13 21:59:31.287: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 7% free 32983K/35399K, paused 82ms
05-13 21:59:31.538: D/dalvikvm(409): GC_CONCURRENT freed 0K, 7% free 32983K/35399K, paused 5ms+4ms
05-13 21:59:31.647: D/dalvikvm(409): GC_FOR_ALLOC freed 1549K, 12% free 31435K/35399K, paused 92ms
05-13 21:59:31.692: I/dalvikvm-heap(409): Grow heap (frag case) to 33.028MB for 2384216-byte allocation
05-13 21:59:31.880: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 11% free 33764K/37767K, paused 100ms
05-13 21:59:32.057: D/dalvikvm(409): GC_CONCURRENT freed <1K, 11% free 33764K/37767K, paused 4ms+4ms
05-13 21:59:32.307: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 11% free 33764K/37767K, paused 108ms
05-13 21:59:32.377: I/dalvikvm-heap(409): Grow heap (frag case) to 37.073MB for 4241380-byte allocation
05-13 21:59:32.547: D/dalvikvm(409): GC_FOR_ALLOC freed 0K, 10% free 37906K/41927K, paused 97ms
05-13 21:59:32.797: D/dalvikvm(409): GC_CONCURRENT freed 0K, 10% free 37906K/41927K, paused 4ms+14ms
05-13 21:59:34.747: D/dalvikvm(409): GC_FOR_ALLOC freed 2329K, 13% free 36533K/41927K, paused 98ms
05-13 21:59:35.037: D/dalvikvm(409): GC_CONCURRENT freed 1304K, 12% free 37261K/41927K, paused 4ms+4ms
05-13 21:59:42.547: D/dalvikvm(409): GC_FOR_ALLOC freed 337K, 11% free 37524K/41927K, paused 88ms
05-13 21:59:42.607: I/dalvikvm-heap(409): Grow heap (frag case) to 41.255MB for 4776976-byte allocation
05-13 21:59:42.801: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 10% free 42188K/46599K, paused 104ms
05-13 21:59:43.021: D/dalvikvm(409): GC_CONCURRENT freed <1K, 10% free 42188K/46599K, paused 4ms+4ms
05-13 21:59:43.180: D/dalvikvm(409): GC_FOR_ALLOC freed <1K, 10% free 42189K/46599K, paused 98ms
05-13 21:59:43.180: I/dalvikvm-heap(409): Forcing collection of SoftReferences for 8494048-byte allocation
05-13 21:59:43.327: D/dalvikvm(409): GC_BEFORE_OOM freed 8K, 10% free 42180K/46599K, paused 143ms
05-13 21:59:43.327: E/dalvikvm-heap(409): Out of memory on a 8494048-byte allocation.
05-13 21:59:43.337: I/dalvikvm(409): "main" prio=5 tid=1 RUNNABLE
05-13 21:59:43.337: I/dalvikvm(409): | group="main" sCount=0 dsCount=0 obj=0x4001b5c8 self=0x125d8
05-13 21:59:43.337: I/dalvikvm(409): | sysTid=409 nice=0 sched=0/0 cgrp=default handle=-1342913432
05-13 21:59:43.337: I/dalvikvm(409): | schedstat=( 10690152881 5424008534 597 ) utm=864 stm=205 core=0
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.nativeCreate(Native Method)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:604)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
05-13 21:59:43.337: I/dalvikvm(409): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
05-13 21:59:43.347: I/dalvikvm(409): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738)
05-13 21:59:43.347: I/dalvikvm(409): at android.content.res.Resources.loadDrawable(Resources.java:1918)
05-13 21:59:43.347: I/dalvikvm(409): at android.content.res.Resources.getDrawable(Resources.java:655)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageView.resolveUri(ImageView.java:510)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageView.setImageResource(ImageView.java:289)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.ImageSwitcher.setImageResource(ImageSwitcher.java:41)
05-13 21:59:43.357: I/dalvikvm(409): at gaurav.rapp.swamiji.BeWithSwamijiActivity$1.onItemClick(BeWithSwamijiActivity.java:39)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.AdapterView.performItemClick(AdapterView.java:282)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.Gallery.onSingleTapUp(Gallery.java:867)
05-13 21:59:43.357: I/dalvikvm(409): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:557)
05-13 21:59:43.357: I/dalvikvm(409): at android.widget.Gallery.onTouchEvent(Gallery.java:842)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.View.dispatchTouchEvent(View.java:4609)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
05-13 21:59:43.377: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.387: I/dalvikvm(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.387: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1709)
05-13 21:59:43.407: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1264)
05-13 21:59:43.407: I/dalvikvm(409): at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
05-13 21:59:43.407: I/dalvikvm(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1682)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.View.dispatchPointerEvent(View.java:4677)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392)
05-13 21:59:43.417: I/dalvikvm(409): at android.view.ViewRoot.handleMessage(ViewRoot.java:2054)
05-13 21:59:43.417: I/dalvikvm(409): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 21:59:43.417: I/dalvikvm(409): at android.os.Looper.loop(Looper.java:132)
05-13 21:59:43.417: I/dalvikvm(409): at android.app.ActivityThread.main(ActivityThread.java:4123)
05-13 21:59:43.417: I/dalvikvm(409): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 21:59:43.417: I/dalvikvm(409): at java.lang.reflect.Method.invoke(Method.java:491)
05-13 21:59:43.417: I/dalvikvm(409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-13 21:59:43.417: I/dalvikvm(409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-13 21:59:43.417: I/dalvikvm(409): at dalvik.system.NativeStart.main(Native Method)
05-13 21:59:43.417: D/AndroidRuntime(409): Shutting down VM
05-13 21:59:43.417: W/dalvikvm(409): threadid=1: thread exiting with uncaught exception (group=0x40014760)
05-13 21:59:43.467: E/AndroidRuntime(409): FATAL EXCEPTION: main
05-13 21:59:43.467: E/AndroidRuntime(409): java.lang.OutOfMemoryError
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.nativeCreate(Native Method)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:604)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.content.res.Resources.loadDrawable(Resources.java:1918)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.content.res.Resources.getDrawable(Resources.java:655)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageView.resolveUri(ImageView.java:510)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageView.setImageResource(ImageView.java:289)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.ImageSwitcher.setImageResource(ImageSwitcher.java:41)
05-13 21:59:43.467: E/AndroidRuntime(409): at gaurav.rapp.swamiji.BeWithSwamijiActivity$1.onItemClick(BeWithSwamijiActivity.java:39)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.AdapterView.performItemClick(AdapterView.java:282)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.Gallery.onSingleTapUp(Gallery.java:867)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:557)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.widget.Gallery.onTouchEvent(Gallery.java:842)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.View.dispatchTouchEvent(View.java:4609)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1709)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1264)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1682)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.View.dispatchPointerEvent(View.java:4677)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.view.ViewRoot.handleMessage(ViewRoot.java:2054)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.os.Looper.loop(Looper.java:132)
05-13 21:59:43.467: E/AndroidRuntime(409): at android.app.ActivityThread.main(ActivityThread.java:4123)
05-13 21:59:43.467: E/AndroidRuntime(409): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 21:59:43.467: E/AndroidRuntime(409): at java.lang.reflect.Method.invoke(Method.java:491)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-13 21:59:43.467: E/AndroidRuntime(409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-13 21:59:43.467: E/AndroidRuntime(409): at dalvik.system.NativeStart.main(Native Method)
05-13 21:59:46.117: I/Process(409): Sending signal. PID: 409 SIG: 9