gpt4 book ai didi

android - 我的 logcat 中出现 SuperNotCalledException

转载 作者:行者123 更新时间:2023-11-29 14:18:56 25 4
gpt4 key购买 nike

这是我的代码:

第一个 Activity::

public class ImageExercise extends Activity {
/** Called when the activity is first created. */

public static int pos;
//static int[] mThumbIds;
//public static int[] mThumbIds;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.image);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Intent intent = new Intent(ImageExercise.this,FullImage.class);
pos=position;
intent.putExtra("pos", pos);
startActivity(intent);
//finish();
}
});
}
}

class ImageAdapter extends BaseAdapter {
static int[] mThumbIds = {
R.drawable.sample_1, R.drawable.sample_2,
R.drawable.sample_3, R.drawable.sample_4,
R.drawable.sample_5, R.drawable.sample_6,
R.drawable.sample_7, R.drawable.sample_8,
R.drawable.sample_9,R.drawable.sample_1,
R.drawable.sample_2,R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_9,
R.drawable.sample_5, R.drawable.sample_6,
R.drawable.sample_7, R.drawable.sample_8
};

private Context mContext;

public ImageAdapter(Context c) {
mContext = c;
}

public int getCount() {
return mThumbIds.length;
}

public Object getItem(int position) {
return null;
}

public long getItemId(int position) {
return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
/* ImageExercise obj = new ImageExercise();
obj.pos = position;*/
imageView.setImageResource(mThumbIds[position]);
return imageView;
}

// references to our images
}

第二个 Activity::

package com.ex.dp;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

public class FullImage extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
//super.onCreate(savedInstanceState);

setContentView(R.layout.fullimage);
Bundle bundle= getIntent().getExtras();
ImageView image = (ImageView) findViewById(R.id.imageView1);

int pos = bundle.getInt("pos");
ImageAdapter obj = new ImageAdapter(this);
image.setImageResource(obj.mThumbIds[pos]);

/*if(pos==0)
{
image.setImageResource(pos);
}*/
}
}

请帮帮我

最佳答案

在 onCreate 中取消注释行 //super.onCreate(savedInstanceState);

关于android - 我的 logcat 中出现 SuperNotCalledException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5089020/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com