2012-02-17 67 views
0

我有这个日志(当然与我的活动崩溃:D)当试图显示一个弹出面板。我已经看到他在繁忙的高级编码器的普通软件教程... 它只发生在我添加弹出类: 任何建议,我可以做的第2行? 问候 日志:MapView:android.view.InflateException:二进制XML文件行#2:错误膨胀类linearLayout

java.lang.RuntimeException: Unable to start activity ComponentInfo{tfe.rma.ciss.be/tfe.rma.ciss.be.TheMap}: android.view.InflateException: 
    Binary XML file line #2: Error inflating class linearLayout 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 
      at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 
      at android.os.Handler.dispatchMessage(Handler.java:99) 
      at android.os.Looper.loop(Looper.java:123) 
      at android.app.ActivityThread.main(ActivityThread.java:3687) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:507) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 
      at dalvik.system.NativeStart.main(Native Method) 
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class linearLayout 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:386) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
      at tfe.rma.ciss.be.TheMap$PopupPanel.<init>(TheMap.java:985) 
      at tfe.rma.ciss.be.TheMap$overlay4.<init>(TheMap.java:663) 
      at tfe.rma.ciss.be.TheMap.onCreate(TheMap.java:353) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 
      ... 11 more 
     Caused by: java.lang.ClassNotFoundException: android.view.linearLayout in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/tfe.rma.ciss.be-2.apk] 
      at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 
      at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 
      at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 
      at android.view.LayoutInflater.createView(LayoutInflater.java:471) 
      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549) 
      at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) 
      ... 18 more 

我的布局:

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



    <com.google.android.maps.MapView 
     android:id="@+id/mapView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:enabled="true" 
     android:clickable="true" 
     android:apiKey="0lcrLCvFHx-8bK4lgE307_CyHXxgbjefMiI3w9w" 
     /> 
     <LinearLayout android:id="@+id/zoom" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     /> 

<SlidingDrawer 
     android:id="@+id/drawer" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:handle="@+id/handle" 
     android:content="@+id/content" 
     > 
     <ImageView 
      android:id="@id/handle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/tray_handle_normal" 
     /> 

     <LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:id="@id/content" 
android:background="@layout/background" 
> 

    <TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:stretchColumns="1,2" 
    > 
    <TableRow> 
     <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingLeft="2dip" 
     android:paddingRight="4dip" 
     android:text="Emplacement : " 
     /> 
     <EditText android:id="@+id/getLat" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:cursorVisible="true" 
     android:editable="true" 
     android:singleLine="true" 
     android:layout_weight="1" 
     android:inputType="numberDecimal" 
     /> 
     <EditText android:id="@+id/getLon" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:cursorVisible="true" 
     android:editable="true" 
     android:singleLine="true" 
     android:layout_weight="1" 
     android:inputType="numberDecimal" 
     /> 
    </TableRow> 
    </TableLayout> 
    <Button android:id="@+id/goMap" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Afficher !" 
    /> 
    <LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:id="@id/content" 
> 
<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/sat" 
android:text="Satellite"> 
</Button> 

<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/normal" 
android:text="normal"> 
</Button> 

<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/traffic" 
android:text="traffic"> 
</Button> 
<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/street" 
android:text="street"> 
</Button> 
</LinearLayout> 

</LinearLayout> 

    </SlidingDrawer> 

</RelativeLayout> 

弹出类:

class PopupPanel { 
     View popup; 
     boolean isVisible=false; 

     PopupPanel(int layout) { 
      ViewGroup parent=(ViewGroup)mapView.getParent(); 

      popup=getLayoutInflater().inflate(layout, parent, false); 

      popup.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
       hide(); 
      } 
      }); 
     } 

     View getView() { 
      return(popup); 
     } 

     void show(boolean alignTop) { 
      RelativeLayout.LayoutParams lp=new RelativeLayout.LayoutParams(
       RelativeLayout.LayoutParams.WRAP_CONTENT, 
       RelativeLayout.LayoutParams.WRAP_CONTENT 
     ); 

      if (alignTop) { 
      lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); 
      lp.setMargins(0, 20, 0, 0); 
      } 
      else { 
      lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 
      lp.setMargins(0, 0, 0, 60); 
      } 

      hide(); 

      ((ViewGroup)mapView.getParent()).addView(popup, lp); 
      isVisible=true; 
     } 

     void hide() { 
      if (isVisible) { 
      isVisible=false; 
      ((ViewGroup)popup.getParent()).removeView(popup); 
      } 
     } 
     } 

回答

3

异常有

Caused by: java.lang.ClassNotFoundException: android.view.linearLayout in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/tfe.rma.ciss.be-2.apk] 

类是LinearLayout(两个大写的L),而不是linearLayout

+0

哪一个LinearLayout?因为在我的布局中似乎都很好 – youssoua 2012-02-17 14:00:25

+0

@youssoua:'PopupPanel'正在膨胀布局。该布局不是您上面显示的布局,它是包含您的“MapView”的布局。而且,既然你说当你去显示面板时发生了崩溃,那么可能是具有有缺陷的XML的那个是你使用'PopupPanel'的布局。 – CommonsWare 2012-02-17 14:13:18

+0

我终于找到了合适的布局,thx :-) – youssoua 2012-02-17 15:01:21

相关问题