Error Inflating When Extending a Class

Error inflating when extending a class

I think I figured out why this wasn't working. I was only providing a constructor for the case of one parameter 'context' when I should have provided a constructor for the two parameter 'Context, AttributeSet' case. I also needed to give the constructor(s) public access. Here's my fix:

public class GhostSurfaceCameraView extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder;
Camera mCamera;

public GhostSurfaceCameraView(Context context)
{
super(context);
init();
}
public GhostSurfaceCameraView(Context context, AttributeSet attrs)
{
super(context, attrs);
init();
}
public GhostSurfaceCameraView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}

Android: error inflating extended class

MyWebView class is internal of MainActivity class. Inflater does not see this class. Make your WebView in defferent .java file.

Also you can try to use that name in your layout file <com.example.test.MainActivity.MyWebView/>, but i'm not sure about it.

Error inflating class android.widget.ImageButton after upgrading app

I'm pretty sure that your problem in styles(styles.xml).

   <style name="DialtactsDialpadButtonStyle">
<item name="android:layout_width">0dip</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:background">?attr/actionBarItemBackground</item>
</style>

Try remove or change line:

<item name="android:background">?attr/actionBarItemBackground</item>

It looks like ?attr/actionBarItemBackground is not found while inflating layout.

Update:

Why it happens and why it is working without fixes on ready apk from https://github.com/r3gis3r/CSipSimple/issues/69 :

In your build ?attr/actionBarItemBackground is not found in theme which is set for ImageButton.
This theme is <style name="DarkTheme.Dialog" parent="Theme.Sherlock.Dialog">

Theme.Sherlock.Dialog was defined in JakeWharton's ActionBarSherlock. But it was removed by commit 601bde214b56b8fad0b4fc5aaed5af0b531b6135

So that's why old apk is working fine while new build(which is using "latest" ActionBarSherlock) is crashing.

Extend RecyclerView : Error Inflating Class com.example.MyRecyclerView

You need to implement the other Constructors too:

 public MyRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public MyRecyclerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

You are creating the MyRecyclerView through XML, thus you need the Constructor with the AttributeSet Parameter.

InflateException i have an Error inflating class

Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]

it means that your custom view Panel is missing the constructor with the context and attributeset:

  public void Panel(Context context, AttributeSet att) {
super(context,att)
}

which is used when the custom view is inflated from the xml



Related Topics



Leave a reply



Submit