When i include a nav bar code xml in my another xml, it generates following error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my/com.my.Login}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
login.xml is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/tableStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
android:layout_height="wrap_content"
layout="#layout/navbar" />
</LinearLayout>
navbar.xml is
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#style/tableRowStyle"
android:orientation="horizontal"
android:paddingRight="0dp" >
<Button
android:id="#+id/button2"
android:layout_width="52dp"
android:layout_height="48dp"
android:background="#drawable/home" />
<View
android:layout_width="1px"
android:layout_height="fill_parent"
android:background="#1f1f1f" />
<View
android:layout_width="1px"
android:layout_height="fill_parent"
android:background="#454545" />
<Button
android:id="#+id/button1"
android:layout_width="190dp"
android:layout_height="48dp"
android:layout_weight="0.35"
android:background="#drawable/stock" />
<View
android:layout_width="1px"
android:layout_height="fill_parent"
android:background="#1f1f1f" />
<View
android:layout_width="1px"
android:layout_height="fill_parent"
android:background="#454545" />
<Button
android:id="#+id/button2"
android:layout_width="52dp"
android:layout_height="48dp"
android:background="#drawable/home" />
</LinearLayout>
What's the problem behind it?
Could it be that
<include
android:layout_height="wrap_content"
layout="#layout/navbar" />
should be
<include
android:layout_height="wrap_content"
android:layout="#layout/navbar" />
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my/com.my.Login}: android.view.InflateException: Binary XML file line #1: Error inflating class
If you got this error means mismatch call of layout in your setContentView(R.id.xml_file);
So first check and make sure if your calling the layout id correctly in your java code.
And just remove style="#style/tableStyle" in your xml . I think it will works.
Specify layout width also.
<include
android:layout_height="wrap_content"
android:layout_width="wrap_content"
layout="#layout/navbar" />
removed android:background="#style/tableRowStyle"
now its working fine. Thank you all for your valuable answers :)
Related
This is the main activity of xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
tools:context="com.example.liew.idelivery.MainActivity">
<LinearLayout
android:orientation="vertical"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_gravity="center"
android:src="#drawable/logo" />
<TextView
android:id="#+id/txtSlogan"
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="center"
android:text="#string/slogan"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="18sp"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<info.hoang8f.widget.FButton
android:id="#+id/btnSignUp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="Sign Up"
android:textColor="#android:color/white"
app:buttonColor="#color/btnSignUp"
app:cornerRadius="4dp"
app:shadowColor="#android:color/black"
app:shadowEnabled="true"
app:shadowHeight="5dp" />
<info.hoang8f.widget.FButton
android:id="#+id/btnSignIn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="Sign In"
android:textColor="#android:color/white"
app:buttonColor="#color/btnSignUp"
app:cornerRadius="4dp"
app:shadowColor="#android:color/black"
app:shadowEnabled="true"
app:shadowHeight="5dp" />
</LinearLayout>
And this is the error that i found in my logcat.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.liew.idelivery, PID: 18266
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.liew.idelivery/com.example.liew.idelivery.MainActivit
y}: android.view.InflateException: Binary XML file line #43: Error inflating
class info.hoang8f.widget.FButton
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2462)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.access$900(ActivityThread.java:164)
I think the error occurred as there is no closing tag for RelativeLayout. If the problem still persists try to attach the MainActivity file as well, I'll check it.
One last suggestion: Try to use ConstraintLayout instead of LinearLayout and RelativeLayout :)
android.view.InflateException: Binary XML file line #43: Error inflating class
Exception arise only there are something wrong in xml file first of all your xml files need to close with the tag
</RelativeLayout>
Other possibility is that custom views which are you using, make sure the views are on the correct path (package name exist with the path)
info.hoang8f.widget.FButton
I want to Create a CheckBox, My compile
sdk version is 23,
Target version is 23,
build tool version is 23.0.0,
in gradle I'hv added
compile 'com.android.support:support-v4:23.2.0',
compile 'com.android.support:appcompat-v7:23.2.0'
both and in menifest given the app theme as android:theme="#style/Theme.AppCompat.Light.NoActionBar" and no specific theme to Activity. when I run my code its throwing
InflateException line number #23 at xml file, problem while inflating kind of
Then I decided to convery a simple ChcekBox to android.support.v7.widget.AppCompatCheckBox but on the xml file Preview its showing Rendering Problems The following classes could not be instantiated:
- android.support.v7.widget.AppCompatCheckBox
Exception Details java.lang.ClassNotFoundException: android.support.v4.widget.TintableCompoundButton
and if i try to run it it gives me class file for android.support.v4.widget.TintableCompoundButton not found.
So, Any one faced this issue?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:id="#+id/lnv_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rlv_header"
android:orientation="vertical">
<android.support.v7.widget.AppCompatCheckBox
android:id="#+id/confirmCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:checked="false"
android:gravity="start"
android:text="#string/personal_confirm_text"
android:textColor="#color/black"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/rlv_next"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="40dp"
android:background="#color/crabfx_light_gray"
android:visibility="gone">
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentTop="true"
android:background="#color/crabfx_green" />
<TextView
android:id="#+id/tv_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:drawablePadding="10dp"
android:drawableRight="#drawable/discloser"
android:gravity="center_vertical"
android:text="#string/lbl_next"
android:textColor="#color/black"
android:textSize="18sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="#color/crabfx_green" />
</RelativeLayout>
</RelativeLayout>
and below is the theme to Application tag in menifest
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
This error comes when I am running the app.
java.lang.RuntimeException: Unable to start activity ComponentInfo :
android.view.InflateException: Binary XML file line #1: Error
inflating class android.widget.GridLayout
<GridLayout 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"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.ankur.shop.HomeActivity"
android:background="#drawable/gradient7">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome"
android:id="#+id/welcomeText"
android:layout_row="0"
android:layout_column="0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/nameText"
android:layout_row="0"
android:layout_column="1" />
<ViewFlipper
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/viewFlipper"
android:layout_row="1"
android:layout_column="0"
android:inAnimation="#color/abc_color_highlight_material"
android:flipInterval="#integer/abc_config_activityDefaultDur">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/picture1" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/picture2" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/picture3" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/picture4" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/picture5" />
</ViewFlipper>
</GridLayout>
As the documentation,
you must be aware that App Widget layouts are based on RemoteViews, which do not support every kind of layout or view widget.
May be your GridView is not allowed where you are trying to use that. A RemoteViews object can support the following layout classes:
FrameLayout
LinearLayout
RelativeLayout
GridLayout
See more at here
Solution
Try using another layout type in your remote view.
You probably using prior than 4.2. which may not support, review that too.
I´m using this Tutorial http://weavora.com/blog/2012/02/23/android-progressbar-with-text/
to implement a progressbar with text into my app.
I encountered following Problem though:
in my xml file it says: "Error parsing xml: unbound prefix"
here is my xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.test2.ChattingActivity"
tools:ignore="MergeRootFrame" >
<View
android:id="#+id/Line1"
android:layout_width="fill_parent"
android:layout_height="1.0dp"
android:layout_alignParentTop="true"
android:background="#android:color/darker_gray" />
<com.example.test2.TextProgressBar
android:id="#+id/progressBarWithText"
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_width="wrap_parent"
android:layout_height="wrap_content"
android:max="100"
android:maxHeight="30dp"
android:minHeight="30dp"
android:progress="70"
android:progressDrawable="#drawable/progressbar"
components:textSize="18dp"
components:textColor="#android:color/black"
components:text="Loading 70%" />
<Button
android:id="#+id/buttonTopic"
style="#style/buttongreywhite"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:drawableLeft="#drawable/ic_action_labels"
android:onClick="openTopicFragment"
android:text="#string/topics" />
<Button
android:id="#+id/buttonLike"
style="#style/buttongreywhite"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:drawableLeft="#drawable/ic_action_good"
android:onClick="likeWhatYouSaid"
android:text="#string/like" />
<View
android:id="#+id/Line2"
android:layout_width="fill_parent"
android:layout_height="1.0dp"
android:layout_alignBottom="#+id/buttonTopic"
android:layout_alignParentLeft="true"
android:background="#android:color/darker_gray" />
</RelativeLayout>
the modified progressbar class is located in com.example.test2
it´s name is TextProgressBar
What am i missing here? There are no other errors in any of my xml files.
I didnt find any answers concering my problem so far. Thank you for your help.
Your components prefix is undefined for your TextProgressBar.
Based on the tutorial you linked you should have the following in your RelativeLayout
xmlns:components="http://schemas.android.com/apk/res/com.example.test2"
I am having some issues with a custom layout (ToDoView is extending TableLayout), and I do not know how to make sure it is under everything else (by everything else, I mean the EditText, and the Buttons).
As of right now, my app crashes with:
12-18 07:11:13.886: E/AndroidRuntime(3228):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.parrishb.todo/com.parrishb.todo.ToDoActivity}:
android.view.InflateException: Binary XML file line #44: Error
inflating class com.parrishb.todo.ToDoView
Here is the xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ToDoActivity" >
<EditText
android:id="#+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:contentDescription="#string/addItemContentDescription"
android:hint="#string/addItemHint" />
<Button
android:id="#+id/pickDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/myEditText"
android:text="Change the Date" />
<Button
android:id="#+id/pickTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/myEditText"
android:layout_toRightOf="#id/pickDate"
android:text="Change the Time" />
<DatePicker
android:id="#+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TimePicker
android:id="#+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.parrishb.todo.ToDoView
android:id="#+id/tdv"
class="com.parrishb.todo.ToDoView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/datePicker"
/>
</RelativeLayout>
Any help would be great!
I realized that in my ToDoView class, I was missing the constructor:
public ToDoView(Context c, AtrributeSet as){
super(c, as);
//...
}
Found at https://stackoverflow.com/a/3739853/1888585