Error inflating class android.widget.CompoundButton
Posted
by
snctln
on Stack Overflow
See other posts from Stack Overflow
or by snctln
Published on 2011-01-04T17:50:05Z
Indexed on
2011/01/04
17:54 UTC
Read the original article
Hit count: 441
[Disclaimer: This has been cross posted on the Android Developers Google Group
I am trying to use a CompoundButton in a project I am working on. Every time I try and use it by declaring it in my layout xml file I receive the error "01-04 12:27:46.471: ERROR/AndroidRuntime(1771): Caused by: android.view.InflateException: Binary XML file line #605: Error inflating class android.widget.CompoundButton"
After fighting the error for a half an hour I decided to try a minimalistic example. I am using the latest eclipse developer tools, and targeting android 2.2 makign the minimum sdk required 2.2 (8).
Here is the activity java code:
package com.example.CompoundButtonExample;
import android.app.Activity;
import android.os.Bundle;
public class CompoundButtonExampleActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Here is the layout xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<CompoundButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
Here is the manifest xml code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.CompoundButtonExample"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".CompoundButtonExampleActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
As you can see it is just the default hello world project that eclipse creates for you when you start a new Android project. It only differs in the fact that I add a "CompoundButton" to the main layout in a vertical LinearLayout.
Can anyone confirm this bug? Or tell me what I am doing wrong?
© Stack Overflow or respective owner