android.view.InflateException:二进制XML文件行#13:错误导致类ViewPager

Ris*_*aju 1 java android android-intent android-layout android-studio

我是Android新手(第1天),我被教导如今ImageView使用显示图像()viewFlipper.ViewFlipper适用于少量图像(5左右).但我无法使用它来显示22个图像,因为我得到一个内存不足错误,并且app力关闭.所以我读到这里的StackExchange更换ViewFlipperViewPager,我也得到了以下错误.

任何帮助将不胜感激.谢谢.

logcat的: 引擎收录.抱歉,对于patebin,我无法在这里很好地格式化logcat.

第二个ActivityJava类:

package com.droidrish.www.rishabhtatiraju;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.Button;
public class photoActivity extends Activity{
ViewPager vf;
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.photography);
    vf = (ViewPager)findViewById(R.id.viewpager);
}   
Run Code Online (Sandbox Code Playgroud)

第二个Activity布局:

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="1"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true">
<ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewpager">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p1"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p2"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p3"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p4"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p5"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p6"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p7"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p8"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p9"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p10"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p11"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p12"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p13"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p14"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p15"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p16"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p17"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p18"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p19"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p20"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p21"/>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/p22"/>
    </ViewPager>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

清单XML:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".photoActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.droidrish.www.rishabhtatiraju.photoActivity" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

ρяσ*_*я K 10

android.view.InflateException:二进制XML文件行#13:错误导致类ViewPager

因为ViewPager在xml中使用但在Activity代码中试图强制转换ViewPagerandroid.support.v4.view.ViewPager类.

android.support.v4.view.ViewPager在xml中使用而不是ViewPager:

<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewpager">
....
</android.support.v4.view.ViewPager>
Run Code Online (Sandbox Code Playgroud)