アプリをテストするたびに、スプラッシュスクリーンの後でクラッシュし、次のようなエラーが発生します。
02-14 13:03:29.305: A/libc(9935): Fatal signal 11 (SIGSEGV) at 0x0000015c (code=1), thread 9935 (ter.planyourday)
と
02-14 13:03:29.260: E/dalvikvm-heap(9935): Out of memory on a 2381200-byte allocation.
私のImageAdapterは次のようになります。
public class ImageAdapter extends BaseAdapter {
private Context context;
private final String[] buttonValues;
public ImageAdapter(Context context, String[] buttonValues) {
this.context = context;
this.buttonValues = buttonValues;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new View(context);
// get layout from mobile.xml
gridView = inflater.inflate(R.layout.mobile, null);
// set image based on selected text
ImageView imageView = (ImageView) gridView
.findViewById(R.id.grid_item_image);
String button = buttonValues[position];
if (button.equals("homework")) {
imageView.setImageResource(R.drawable.button_homework);
} else if (button.equals("schedule")) {
imageView.setImageResource(R.drawable.button_schedule);
} else if(button.equals("planner")) {
imageView.setImageResource(R.drawable.button_planner);
}else{
imageView.setImageResource(R.drawable.button_settings);
}
} else {
gridView = (View) convertView;
}
return gridView;
}
@Override
public int getCount() {
return buttonValues.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
}
そしてここで主な活動の方法:
static final String[] MOBILE_OS = new String[] { "homework", "schedule",
"planner", "settings" };
private void setGridView() {
gridView = (GridView) findViewById(R.id.gridView1);
gridView.setAdapter(new ImageAdapter(this, MOBILE_OS));
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
switch (position) {
case 0:
Intent startHomework = new Intent(HomeScreen.this,
HomeworkScreen.class);
HomeScreen.this.startActivity(startHomework);
break;
case 1:
Intent startSchedule = new Intent(HomeScreen.this,
ScheduleScreen.class);
HomeScreen.this.startActivity(startSchedule);
break;
case 2:
Intent startPlanner = new Intent(HomeScreen.this,
PlannerScreen.class);
HomeScreen.this.startActivity(startPlanner);
break;
case 3:
Intent startSettings = new Intent(HomeScreen.this,
SettingScreen.class);
HomeScreen.this.startActivity(startSettings);
break;
}
}
});
}
誰かが私を助けてくれることを願っています!
よろしくお願いします;)Wouter