圆形指针

时间:2012-11-29 08:21:18

标签: android

在为页面滑动制作圆形页面指示器时,我遇到错误

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >    

      <RelativeLayout  android:orientation="horizontal" android:id="@+id/winyear"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:background="#36648B" >   

    <TextView android:layout_width="wrap_content" android:text="Product" android:layout_centerInParent="true"
             android:layout_height="wrap_content" android:id="@+id/produt" />

        </RelativeLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager" android:layout_below="@+id/winyear"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />

   <com.viewpagerindicator.CirclePageIndicator
        android:id="@+id/indicator" android:layout_below="@+id/pager"
         android:padding="10dip" 
         android:layout_height="wrap_content"
          android:layout_width="fill_parent" /> 

</RelativeLayout>

public class Details extends FragmentActivity{


    ViewPager pager;
  MyFragmentPagerAdapter pagerAdapter;     

 CirclePageIndicator mIndicator;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.detail);    
    pager = (ViewPager) findViewById(R.id.pager);

    FragmentManager fm = getSupportFragmentManager();      
    pagerAdapter = new MyFragmentPagerAdapter(fm,currency);   
      pager.setAdapter(pagerAdapter);


      mIndicator = (CirclePageIndicator)findViewById(R.id.indicator);
      mIndicator.setViewPager(pager);
   }
  

11-29 13:08:52.579:E / AndroidRuntime(470):致命异常:主要       11-29 13:08:52.579:E / AndroidRuntime(470):java.lang.RuntimeException:无法启动活动ComponentInfo {com.contract / com.contract.Details}:android.view.InflateException:二进制XML文件行# 34:错误膨胀类com.viewpagerindicator.CirclePageIndicator       11-29 13:08:52.579:E / AndroidRuntime(470):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.app.ActivityThread.access $ 1500(ActivityThread.java:117)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:931)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.os.Handler.dispatchMessage(Handler.java:99)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.os.Looper.loop(Looper.java:123)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.app.ActivityThread.main(ActivityThread.java:3683)       11-29 13:08:52.579:E / AndroidRuntime(470):at java.lang.reflect.Method.invokeNative(Native Method)       11-29 13:08:52.579:E / AndroidRuntime(470):at java.lang.reflect.Method.invoke(Method.java:507)       11-29 13:08:52.579:E / AndroidRuntime(470):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)       11-29 13:08:52.579:E / AndroidRuntime(470):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)       11-29 13:08:52.579:E / AndroidRuntime(470):at dalvik.system.NativeStart.main(Native Method)       11-29 13:08:52.579:E / AndroidRuntime(470):引起:android.view.InflateException:二进制XML文件行#34:错误扩展类com.viewpagerindicator.CirclePageIndicator       11-29 13:08:52.579:E / AndroidRuntime(470):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.view.LayoutInflater.rInflate(LayoutInflater.java:623)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.view.LayoutInflater.inflate(LayoutInflater.java:408)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.view.LayoutInflater.inflate(LayoutInflater.java:320)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.view.LayoutInflater.inflate(LayoutInflater.java:276)       11-29 13:08:52.579:E / AndroidRuntime(470):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.app.Activity.setContentView(Activity.java:1657)       11-29 13:08:52.579:E / AndroidRuntime(470):at com.contract.Details.onCreate(Details.java:36)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)       11-29 13:08:52.579:E / AndroidRuntime(470):... 11更多       11-29 13:08:52.579:E / AndroidRuntime(470):引起:java.lang.ClassNotFoundException:com.viewpagerindicator.CirclePageIndicator in loader dalvik.system.PathClassLoader [/data/app/com.contract-1.apk ]       11-29 13:08:52.579:E / AndroidRuntime(470):at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)       11-29 13:08:52.579:E / AndroidRuntime(470):at java.lang.ClassLoader.loadClass(ClassLoader.java:551)       11-29 13:08:52.579:E / AndroidRuntime(470):at java.lang.ClassLoader.loadClass(ClassLoader.java:511)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.view.LayoutInflater.createView(LayoutInflater.java:471)       11-29 13:08:52.579:E / AndroidRuntime(470):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)       11-29 13:08:52.579:E / AndroidRuntime(470):... 20多个       11-29 13:13:52.652:I / Process(470):发送信号。 PID:470 SIG:9

1 个答案:

答案 0 :(得分:1)

当我遇到同样的问题时,这对我来说很奇怪。我正在开发的应用程序工作正常,直到我在应用程序的build.gradle文件中重新排序了几个依赖库。恢复原始顺序后,应用程序成功运行。

**使用这两者同时发现也会产生同样的问题,所以只使用你需要的一个。

compile 'com.google.android.gms:play-services:7.5.0'*/
compile 'com.google.android.gms:play-services-analytics:7.5.0'

**仅使用编译'com.google.android.gms:play-services-analytics:7.5.0'解决了这个问题。