gpt4 book ai didi

android - 全屏图库安卓

转载 作者:行者123 更新时间:2023-11-29 21:01:31 26 4
gpt4 key购买 nike

对不起我的英语。有一个迷你画廊,当您单击画廊中的图像时,它应该(图片)以全屏方式打开。应用程序只需按下图像即可抛出。我究竟做错了什么?主要 Activity

public class MainAcTwo extends Activity {

@SuppressWarnings("deprecation")
Gallery gallery;
ImageView bigimage;

@SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.two);
gallery=(Gallery) findViewById(R.id.gallery);
gallery.setAdapter(new ImageAdapter(this));

gallery.setOnItemClickListener(new OnItemClickListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {

long imageId = ImageAdapter.ThumbsIds[position];

Intent fullScreenIntent = new Intent(v.getContext(), FullScreenImage.class);
fullScreenIntent.putExtra(MainAcTwo.class.getName(), imageId);

MainAcTwo.this.startActivity(fullScreenIntent);

}
});
}

图像适配器

public class ImageAdapter extends BaseAdapter implements SpinnerAdapter {

private Context context;

public ImageAdapter(Context context) {
// TODO Auto-generated constructor stub
this.context = context;
}

@Override
public int getCount() {
// TODO Auto-generated method stub
return ThumbsIds.length;
}

@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}

@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}

@Override
public View getView(final int position, View convertView, ViewGroup arg2) {
// TODO Auto-generated method stub
ImageView imageView=null;
if(convertView == null) {
imageView = new ImageView(context);
imageView.setLayoutParams(new Gallery.LayoutParams(215, 200));
imageView.setPadding(8, 8, 8, 8);


}else {
imageView = (ImageView) convertView;
}

imageView.setImageResource(ThumbsIds[position]);

return imageView;
}

public static Integer[] ThumbsIds={
R.drawable.abs_icla,
R.drawable.abs_dog,
R.drawable.abs_flow,
R.drawable.abs_neb,
R.drawable.abs_rad
};

全屏图片

public class FullScreenImage extends Activity {

protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.full_image);
Intent intent = getIntent();
long imageId = (Long) intent.getExtras().get(FullScreenImage.class.getName());

ImageView imageView = (ImageView) findViewById(R.id.fullImage);

imageView.setLayoutParams( new ViewGroup.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT));

imageView.setImageResource((int) imageId);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
}

最佳答案

如果它不起作用,请清理你的项目

 imageView.setLayoutParams( new ViewGroup.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT));


change it to

imageView.setLayoutParams( new LinearLayout.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT));

关于android - 全屏图库安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25960180/

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