这是我的第一个问题,但这个论坛在过去的两个月里帮助了我很多!!!
我试图在我的 Android 应用程序上创建一个“画廊”,我为 1 个画廊解决了这个问题,但是在我尝试制作更多“画廊”之后,我的“OnCreate”中出现错误。这是我的 onCreate:
public void onCreate(Bundle savedInstanceState) {
//try {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_combination);
Gallery h = (Gallery) findViewById(R.id.gallery_head);
h.setAdapter(new ImageAdapter_head(this));
h.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
Toast.makeText(Create_combination.this, "" + position,
Toast.LENGTH_SHORT).show();
}
});
我做了3次(3个画廊)
我的班级“ImageAdapter:head”:
public class ImageAdapter_head extends BaseAdapter {
int mGalleryItemBackground;
private Context hContext;
private Integer[] mImageIds_head = { R.drawable.layout, R.drawable.ic_launcher,
R.drawable.test2, R.drawable.layout, R.drawable.layout,
R.drawable.layout, R.drawable.layout };
public ImageAdapter_head(Create_combination create_combination) {
// TODO Auto-generated constructor stub
}
public void ImageAdapter(Context h) {
hContext = h;
TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
mGalleryItemBackground = a.getResourceId(
R.styleable.Gallery1_android_galleryItemBackground , 0);
a.recycle();
}
public int getCount() {
return mImageIds_head.length;
//return mImageIds_upper.length;
//return mImageIds_lower.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
ImageView h = new ImageView(hContext);
@SuppressWarnings("deprecation")
public View getView(int position, View convertView, ViewGroup parent) {
h.setImageResource(mImageIds_head[position]);
h.setLayoutParams(new Gallery.LayoutParams(150, 100));
h.setScaleType(ImageView.ScaleType.FIT_XY);
h.setBackgroundResource(mGalleryItemBackground);
return (h);
}
}
这是我的错误:
Thread [<1> main] (Suspended (exception RuntimeException))
<VM does not provide monitor information>
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1956
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1981
ActivityThread.access$600(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 123
ActivityThread$H.handleMessage(Message) line: 1147
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 137
ActivityThread.main(String[]) line: 4424
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 511
ZygoteInit$MethodAndArgsCaller.run() line: 784
ZygoteInit.main(String[]) line: 551
NativeStart.main(String[]) line: not available [native method]
Thread [<10> Binder Thread #2] (Running)
Thread [<9> Binder Thread #1] (Running)
Daemon Thread [<8> FinalizerWatchdogDaemon] (Running)
Daemon Thread [<7> FinalizerDaemon] (Running)
Daemon Thread [<6> ReferenceQueueDaemon] (Running)
Thread [<11> AsyncTask #1] (Running)
日志猫:
11-18 18:24:07.371: I/ActivityManager(159): START {cmp=in.dressin/com.example.hellogallery.Create_combination} from pid 1890
11-18 18:24:07.511: D/dalvikvm(159): GC_CONCURRENT freed 552K, 20% free 9123K/11335K, paused 3ms+7ms
11-18 18:24:07.901: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:07.901: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:07.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:07.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:08.401: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:08.401: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:08.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:08.411: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:08.901: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:08.901: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:08.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:08.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:09.401: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:09.401: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:09.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:09.411: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:09.911: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:09.911: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:09.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:09.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:10.411: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:10.411: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:10.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:10.411: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:10.901: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:10.901: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:10.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:10.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:11.401: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:11.401: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:11.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:11.411: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:11.901: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:11.901: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:11.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:11.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:12.431: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:12.431: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:12.441: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:12.441: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:12.911: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:12.911: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:12.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:12.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:13.401: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:13.401: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:13.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:13.411: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:13.901: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:13.901: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:13.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:13.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:14.401: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:14.401: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:14.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:14.411: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:14.901: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:14.901: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:14.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:14.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:15.401: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:15.401: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:15.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:15.411: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:15.911: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:15.911: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:15.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:15.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:16.411: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:16.411: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:16.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:16.411: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:16.901: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:16.901: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:16.911: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:16.911: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:17.401: I/Process(159): Sending signal. PID: 1890 SIG: 3
11-18 18:24:17.401: I/dalvikvm(1890): threadid=3: reacting to signal 3
11-18 18:24:17.401: W/ActivityManager(159): Launch timeout has expired, giving up wake lock!
11-18 18:24:17.411: D/dalvikvm(1890): threadid=1: still suspended after undo (sc=1 dc=1)
11-18 18:24:17.421: I/dalvikvm(1890): Wrote stack traces to '/data/anr/traces.txt'
11-18 18:24:17.421: W/ActivityManager(159): Activity idle timeout for ActivityRecord{411fec30 in.dressin/com.example.hellogallery.Create_combination}
11-18 18:24:20.261: I/WindowManager(159): MediaPlayer.is not PlayingVideo
11-18 18:24:22.971: I/WindowManager(159): MediaPlayer.is not PlayingVideo
11-18 18:24:28.741: I/InputDispatcher(159): Application is not responding: AppWindowToken{412958e0 token=Token{413a5178 ActivityRecord{411fec30 in.dressin/com.example.hellogallery.Create_combination}}}. 5001.1ms since event, 5000.8ms since wait started
11-18 18:24:28.741: I/WindowManager(159): Input event dispatching timed out sending to application AppWindowToken{412958e0 token=Token{413a5178 ActivityRecord{411fec30 in.dressin/com.example.hellogallery.Create_combination}}}
11-18 18:24:33.741: I/InputDispatcher(159): Dropped event because it is stale.
请帮我 :)
问候,菲利克斯!