java.lang.RuntimeException: Unable to start activity `ComponentInfo{com.example.demo/com.example.demo.Demo}: android.view.InflateException: Binary XML file line #7: Error inflating class com.example.component.MainActivity`
public class MainActivity extends FrameLayout { public MainActivity(Context context) { super(context); // TODO Auto-generated constructor stub } }
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
デモ.java
public class Demo extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
}
}
activity_demo.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.example.component.MainActivity
android:id="@+id/comp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</FrameLayout>