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
Android Timer Updating a Textview (Ui)
Best Way to Implement View.Onclicklistener in Android
How to Save Bitmap to Android Gallery
Java Doesn't Work with Regex \S, Says: Invalid Escape Sequence
Android: Email Client Receiver Email Id Empty in Android-Parse
Sort Data to Recyclerview Based on Latest Date from Firebase
Stream Live Android Audio to Server
Hosting an Executable Within Android Application
How to Download Older Google Play Services
Full Screen Videoview Without Stretching the Video
How to Select and Crop an Image in Android
Android Archive Library (Aar) VS Standard Jar
Asynctask.Executeonexecutor() Before API Level 11
Android: Dex Cannot Parse Version 52 Byte Code
Reading a JSON Array in Android
String.Equals() with Multiple Conditions (And One Action on Result)