【发布时间】:2014-08-23 07:00:47
【问题描述】:
所以我有这个 XML 问题是当我打开它时,它会强制我关闭。当我删除一些图像视图时,可以说只有 7 个 XML 中的总图像视图可以工作。知道为什么吗?我不知道为什么当我的 xml 上有更多图像时它不起作用
App3.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/JCBG"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="Products"
android:textColor="@color/JCLogo"
android:textSize="30dp"/>
<ViewFlipper
android:id="@+id/fliping"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- The child Views/Layout to flip -->
<!-- Layout 1 for 1st Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal|center"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/gr" />
</LinearLayout>
<!-- Layout 2 for 2nd Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/calvitcdetails" />
</LinearLayout>
<!-- Layout 3 for 3rd Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/kapedetails"/>
</LinearLayout>
<!-- Layout 4 for 4th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/glutafitdetails"/>
</LinearLayout>
<!-- Layout 5 for 5th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/pgtdetails"/>
</LinearLayout>
<!-- Layout 6 for 6th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/hilifedetails"/>
</LinearLayout>
<!-- Layout 7 for 7th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/organicbarleyjuicedetails"/>
</LinearLayout>
<!-- Layout 8 for 8th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/barleydetails"/>
</LinearLayout>
<!-- Layout 9 for 9th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/spirulinadetails"/>
</LinearLayout>
<!-- Layout 10 for 10th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/omnisoapdetails"/>
</LinearLayout>
<!-- Layout 11 for 11th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/omnipinkishdetails"/>
</LinearLayout>
<!-- Layout 12 for 12th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/omnidaydetails"/>
</LinearLayout>
<!-- Layout 13 for 13th Screen -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView13"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:scaleType="fitXY"
android:src="@drawable/omnitonerdetails"/>
</LinearLayout>
</ViewFlipper>
</LinearLayout>
Activity3.java
package com.example.jcw;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.widget.ViewFlipper;
public class activity3 extends Activity
{
private ViewFlipper vf;
private float lastX;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.app3);
vf = (ViewFlipper) findViewById(R.id.fliping);
}
public boolean onTouchEvent(MotionEvent touchevent) {
switch (touchevent.getAction()) {
case MotionEvent.ACTION_DOWN: {
lastX = touchevent.getX();
break;
}
case MotionEvent.ACTION_UP: {
float currentX = touchevent.getX();
if (lastX < currentX) {
if (vf.getDisplayedChild() == 0)
break;
vf.setInAnimation(this, R.anim.in_from_left);
vf.setOutAnimation(this, R.anim.out_to_right);
vf.showNext();
}
if (lastX > currentX) {
if (vf.getDisplayedChild() == 1)
break;
vf.setInAnimation(this, R.anim.in_from_right);
vf.setOutAnimation(this, R.anim.out_to_left);
vf.showPrevious();
}
break;
}
}
return false;
}
}
【问题讨论】:
-
请发布您的日志猫
-
我的 LOGCAT notepad.cc/share/pPSPyDmYdZ
-
用于处理内存不足。检查这个stackoverflow.com/questions/18685835/…
标签: android android-layout android-activity forceclose