Android 全屏图像库
对不起我的英语。有一个迷你图库,当您单击图库中的图像时,它应该(图片)全屏打开。应用程序只需按下图像即可抛出。我做错了什么? 主要活动Android 全屏图像库,android,fullscreen,Android,Fullscreen,对不起我的英语。有一个迷你图库,当您单击图库中的图像时,它应该(图片)全屏打开。应用程序只需按下图像即可抛出。我做错了什么? 主要活动 public class MainAcTwo extends Activity { @SuppressWarnings("deprecation") Gallery gallery; ImageView bigimage; @SuppressWarnings("deprecation") public void onCreate(Bundle savedIn
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);
}
});
}
}
全屏图像
公共类FullScreenImage扩展活动{
}如果项目不起作用,请清理项目
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));
它抛出的错误是什么?在哪一行?当我单击图像时,在logCat中写入“不幸的是,MyProject已停止”:致命异常:main java.lang.ClassCastException:android.view.ViewGroup$LayoutParams不能强制转换为android.widget.LinearLayout$LayoutParams或android.widget.LinearLayout.measureVerticalandroid.widget.LinearLayout.onMeasure(LinearLayout.java:574)android.view.view.measure(LinearLayout.java:655)android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)android.widget.FrameLayout.onMeasure(FrameLayout.java:310)android.view.view.view.measure(view.java:15172)_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu!
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));