我一直在尝试使用eclipse为我在
上运行的应用程序创建一个Pager 05-14 23:08:26.141: D/InputEventConsistencyVerifier(1213): KeyEvent: ACTION_UP but key was not down.
05-14 23:08:26.141: D/InputEventConsistencyVerifier(1213): in android.widget.EditText@411ec408
05-14 23:08:26.141: D/InputEventConsistencyVerifier(1213): 0: sent at 2935967000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=2935967, downTime=2935835, deviceId=0, source=0x101 }
05-14 23:08:30.211: D/AndroidRuntime(1213): Shutting down VM
05-14 23:08:30.211: W/dalvikvm(1213): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
05-14 23:08:30.271: E/AndroidRuntime(1213): FATAL EXCEPTION: main
05-14 23:08:30.271: E/AndroidRuntime(1213): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.madrobo/com.example.madrobo.MainPage}: android.view.InflateException: Binary XML file line #6: Error inflating class support.v4.view.ViewPager
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.ActivityThread.access$600(ActivityThread.java:130)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.os.Looper.loop(Looper.java:137)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-14 23:08:30.271: E/AndroidRuntime(1213): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 23:08:30.271: E/AndroidRuntime(1213): at java.lang.reflect.Method.invoke(Method.java:511)
05-14 23:08:30.271: E/AndroidRuntime(1213): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-14 23:08:30.271: E/AndroidRuntime(1213): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-14 23:08:30.271: E/AndroidRuntime(1213): at dalvik.system.NativeStart.main(Native Method)
05-14 23:08:30.271: E/AndroidRuntime(1213): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class support.v4.view.ViewPager
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-14 23:08:30.271: E/AndroidRuntime(1213): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.Activity.setContentView(Activity.java:1867)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
05-14 23:08:30.271: E/AndroidRuntime(1213): at com.example.madrobo.MainPage.onCreate(MainPage.java:25)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.Activity.performCreate(Activity.java:5008)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
05-14 23:08:30.271: E/AndroidRuntime(1213): ... 11 more
05-14 23:08:30.271: E/AndroidRuntime(1213): Caused by: java.lang.ClassNotFoundException: support.v4.view.ViewPager
05-14 23:08:30.271: E/AndroidRuntime(1213): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-14 23:08:30.271: E/AndroidRuntime(1213): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-14 23:08:30.271: E/AndroidRuntime(1213): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
05-14 23:08:30.271: E/AndroidRuntime(1213): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
05-14 23:08:30.271: E/AndroidRuntime(1213): ... 24 more
05-14 23:08:31.481: I/Process(1213): Sending signal. PID: 1213 SIG: 9
05-14 23:28:17.342: E/Trace(1261): error opening trace file: No such file or directory (2)
05-14 23:28:18.092: D/dalvikvm(1261): GC_FOR_ALLOC freed 82K, 8% free 5354K/5763K, paused 35ms, total 37ms
05-14 23:28:18.102: I/dalvikvm-heap(1261): Grow heap (frag case) to 6.964MB for 1523728-byte allocation
05-14 23:28:18.161: D/dalvikvm(1261): GC_CONCURRENT freed <1K, 7% free 6841K/7303K, paused 15ms+3ms, total 59ms
05-14 23:28:18.311: D/dalvikvm(1261): GC_FOR_ALLOC freed 0K, 7% free 6841K/7303K, paused 26ms, total 26ms
05-14 23:28:18.311: I/dalvikvm-heap(1261): Grow heap (frag case) to 7.781MB for 857104-byte allocation
05-14 23:28:18.381: D/dalvikvm(1261): GC_CONCURRENT freed 0K, 7% free 7678K/8199K, paused 16ms+14ms, total 62ms
05-14 23:28:18.531: I/Choreographer(1261): Skipped 51 frames! The application may be doing too much work on its main thread.
05-14 23:28:18.541: D/gralloc_goldfish(1261): Emulator without GPU emulation detected.
05-14 23:28:47.752: I/Choreographer(1261): Skipped 32 frames! The application may be doing too much work on its main thread.
05-14 23:28:53.212: I/Choreographer(1261): Skipped 31 frames! The application may be doing too much work on its main thread.
05-14 23:28:56.481: D/InputEventConsistencyVerifier(1261): KeyEvent: ACTION_UP but key was not down.
05-14 23:28:56.481: D/InputEventConsistencyVerifier(1261): in android.widget.EditText@411ec420
05-14 23:28:56.481: D/InputEventConsistencyVerifier(1261): 0: sent at 4166293000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=4166293, downTime=4166229, deviceId=0, source=0x101 }
05-14 23:28:59.902: D/AndroidRuntime(1261): Shutting down VM
05-14 23:28:59.902: W/dalvikvm(1261): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
05-14 23:28:59.952: E/AndroidRuntime(1261): FATAL EXCEPTION: main
05-14 23:28:59.952: E/AndroidRuntime(1261): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.madrobo/com.example.madrobo.MainPage}: android.view.InflateException: Binary XML file line #6: Error inflating class support.v4.view.ViewPager
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.ActivityThread.access$600(ActivityThread.java:130)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.os.Looper.loop(Looper.java:137)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-14 23:28:59.952: E/AndroidRuntime(1261): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 23:28:59.952: E/AndroidRuntime(1261): at java.lang.reflect.Method.invoke(Method.java:511)
05-14 23:28:59.952: E/AndroidRuntime(1261): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-14 23:28:59.952: E/AndroidRuntime(1261): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-14 23:28:59.952: E/AndroidRuntime(1261): at dalvik.system.NativeStart.main(Native Method)
05-14 23:28:59.952: E/AndroidRuntime(1261): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class support.v4.view.ViewPager
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-14 23:28:59.952: E/AndroidRuntime(1261): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.Activity.setContentView(Activity.java:1867)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
05-14 23:28:59.952: E/AndroidRuntime(1261): at com.example.madrobo.MainPage.onCreate(MainPage.java:25)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.Activity.performCreate(Activity.java:5008)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
05-14 23:28:59.952: E/AndroidRuntime(1261): ... 11 more
05-14 23:28:59.952: E/AndroidRuntime(1261): Caused by: java.lang.ClassNotFoundException: support.v4.view.ViewPager
05-14 23:28:59.952: E/AndroidRuntime(1261): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-14 23:28:59.952: E/AndroidRuntime(1261): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-14 23:28:59.952: E/AndroidRuntime(1261): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
05-14 23:28:59.952: E/AndroidRuntime(1261): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
05-14 23:28:59.952: E/AndroidRuntime(1261): ... 24 more
这是我的xml文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android:support.v4.view.ViewPager
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/viewpage">
</android:support.v4.view.ViewPager>
<TextView
android:id="@+id/welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:text="Welcome" />
<TextView
android:id="@+id/nam"
android:layout_marginLeft="130dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</RelativeLayout>
还添加库Order和Expert enter image description here
活动代码
package com.example.madrobo;
import java.util.ArrayList;
import java.util.List;
import com.example.adapter.MyFragmentPagerAdapter;
import com.example.fragments.Fragment1;
import com.example.fragments.Fragment2;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
public class MainPage extends ActionBarActivity {
ViewPager viewpager;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mainpage);
viewpager=(ViewPager) findViewById(R.id.viewpage);
List<Fragment> listFragments=new ArrayList<Fragment>();
listFragments.add(new Fragment1());
listFragments.add(new Fragment2());
MyFragmentPagerAdapter myfragmentpager=new MyFragmentPagerAdapter(getSupportFragmentManager(),listFragments);
viewpager.setAdapter(myfragmentpager);
}
}
关于如何解决此问题的任何想法?
答案 0 :(得分:2)
您的xml文件中有拼写错误。
这是android.support.v4.view.ViewPager
不是android:support.v4.view.ViewPager