2013-03-12 6 views
0

J'essaye de gonfler un XML (Layout) à l'intérieur d'un AlertBox.Exception ClassNotFound lors du gonflage Afficher dans une zone AlertBox

Voici le XML que je veux gonfler ...

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

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/update_information" /> 

    <CheckBox 
     android:id="@+id/chbDisplay" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Don't Show Again" 
     android:checked="true" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

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

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



    </LinearLayout> 

</LinearLayout> 

C'est le code que je utilise pour gonfler le XML ...

private void display_Update_Info() { 
     // TODO Auto-generated method stub 

     LayoutInflater in = new LayoutInflater(this) { 

      @Override 
      public LayoutInflater cloneInContext(Context newContext) { 
       // TODO Auto-generated method stub 
       return null; 
      }//This code is auto generated. I have no idea what is this... 
     }; 

     final View update = in.inflate(R.layout.updateinformation, null); 


     AlertDialog.Builder updateInfo = new Builder(this); 
     updateInfo.setView(update); 
     updateInfo.show(); 

    } 

Voici la trace Logcat. ..

03-12 16:15:38.929: E/AndroidRuntime(9021): FATAL EXCEPTION: main 
03-12 16:15:38.929: E/AndroidRuntime(9021): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobilevoiceapps.advancedvoicecalculatorfree/com.mobilevoiceapps.advancedvoicecalculatorfree.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class CheckBox 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.os.Handler.dispatchMessage(Handler.java:99) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.os.Looper.loop(Looper.java:130) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.app.ActivityThread.main(ActivityThread.java:3687) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at java.lang.reflect.Method.invokeNative(Native Method) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at java.lang.reflect.Method.invoke(Method.java:507) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at dalvik.system.NativeStart.main(Native Method) 
03-12 16:15:38.929: E/AndroidRuntime(9021): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class CheckBox 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at com.mobilevoiceapps.advancedvoicecalculatorfree.MainActivity.display_Update_Info(MainActivity.java:469) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at com.mobilevoiceapps.advancedvoicecalculatorfree.MainActivity.onCreate(MainActivity.java:160) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  ... 11 more 
03-12 16:15:38.929: E/AndroidRuntime(9021): Caused by: java.lang.ClassNotFoundException: android.view.CheckBox in loader dalvik.system.PathClassLoader[/data/app/com.mobilevoiceapps.advancedvoicecalculatorfree-1.apk] 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.view.LayoutInflater.createView(LayoutInflater.java:471) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) 
03-12 16:15:38.929: E/AndroidRuntime(9021):  ... 19 more 

aussi, si quelqu'un peut me dire, quelle est l'utilisation du code généré automatiquement ...

@Override 
public LayoutInflater cloneInContext(Context newContext) { 
// TODO Auto-generated method stub 
return null; 
} 

Je reçois près de force quand je suis en train d'exécuter l'application ...

Répondre

0

au lieu de cette

LayoutInflater in = new LayoutInflater(this) { 

     @Override 
     public LayoutInflater cloneInContext(Context newContext) { 
      // TODO Auto-generated method stub 
      return null; 
     }//This code is auto generated. I have no idea what is this... 
    }; 

utilisent ce

LayoutInflater in = getLayoutInflater(); 

et pour la deuxième partie voir les docs API http://developer.android.com/reference/android/view/LayoutInflater.html#cloneInContext(android.content.Context).

+0

Parfait ... Merci !!! –

+0

vous êtes welcom :) – stinepike

Questions connexes