Android AppWidget - Error inflating view: Failed to resolve attribute at index - android

I have an AppWidget that is producing this error:
W/AppWidgetHostView: updateAppWidget couldn't find any view, using
error view
android.view.InflateException: Binary XML file line #2: Failed to
resolve attribute at index 1: TypedValue{t=0x2/d=0x7f01009a a=-1}
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute
at index 1: TypedValue{t=0x2/d=0x7f01009a a=-1}
I can tell the error is being caused by inflation of a layout, and I can pin it to the creation of a new RemoteViews in my RemoteViewsService.RemoteViewsFactory subclass' getViewAt() method:
#Override
public RemoteViews getViewAt(int position) {
[…]
final RemoteViews views = new RemoteViews(getPackageName(),
R.layout.appwidget_list_item);
[…]
return views;
}
Commenting this line out removes this particular error, and yet I cannot figure out what is wrong with the layout file it is referencing.
Layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_view"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?listPreferredItemHeight">
<TextView
android:id="#+id/item_name"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center_vertical"
android:paddingEnd="?listPreferredItemPaddingRight"
android:paddingStart="?listPreferredItemPaddingLeft"/>
</LinearLayout>

The error is cause by using using theme attributes (such as ?listPreferredItemHeight) in an AppWidget layout, which isn't possible. These are the "unresolved attribute(s)" the error is referring to.

Related

Draggableview number fornat exception

Below is my XML code:
<com.github.pedrovgs.DraggableView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:draggable_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/draggable_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
draggable_view:enable_minimized_horizontal_alpha_effect="true"
draggable_view:top_view_height="200dp"
draggable_view:top_view_id="#+id/image"
draggable_view:bottom_view_id="#+id/ll"
draggable_view:top_view_margin_bottom="50dp"
draggable_view:top_view_margin_right="10dp"
draggable_view:top_view_resize="true"
draggable_view:top_view_x_scale_factor="2.3"
draggable_view:top_view_y_scale_factor="2.3">
<ImageView
android:id="#+id/image"
android:background="#drawable/imgone"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.github.pedrovgs.DraggableView>
I supposed to have dragabble view in my app.while running my app the following error throws:
Caused by: android.view.InflateException: Binary XML file line #8: For input string: "200.0dip"
Caused by: java.lang.NumberFormatException: For input string: "200.0dip"
There's a bug in that random github library you're using. It doesn't see 200dp as a number, presumably because its not expecting dp there. You're going to have to fix it yourself or contact the author and see if he's willing to do so. Or not use dp, and code around the scaling issues somehow.

How to apply EmojiCompat at Android RemoteView(Notification)

I've tried to apply EmojiCompatibility at Notification's RemoteView.
The app crashed when using EmojiTextView at RemoteView(Notification).
<android.support.text.emoji.widget.EmojiTextView
android:id="#+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
And I also tried another(java code)
EmojiCompat.get().registerInitCallback(new EmojiCompat.InitCallback() {
#Override
public void onInitialized() {
final EmojiCompat compat = EmojiCompat.get();
remoteViews.setTextViewText(R.id.tv_name,
compat.process("item.getEmoticon()");
}
});
How can I use it at RemoteView?
Error code (when applying EmojiTextView at Layout.)
couldn’t inflate view for notification
android.view.InflateException: Binary XML file line #39: Error
inflating class android.support.text.emoji.widget.EmojiTextView
Couldn't expand RemoteViews for: StatusBarNotification
You cannot use emojicompat for remoteviews.

Error inflating row layout in a listview

I'm trying to implement flowtextview into bauerca / drag-sort-listview but I'm getting an error inflating a row. Could you help me?
Error line is in (ResourceDragSortCursorAdapter.java (Bauerca)):
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return mInflater.inflate(mLayout, parent, false);
}
Eclipse says:
Ecipse says "FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #8: Error inflataing class com.pagesuite.flowtext.FlowTextView"
The row layout is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="67dp"
android:orientation="horizontal">
<com.pagesuite.flowtext.FlowTextView
android:id="#+id/nuevo_ingr_row_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#id/drag_handle"
android:layout_width="wrap_content"
android:layout_height="67dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="10dip"
android:background="#drawable/ic_move" />
<ImageView
android:id="#id/click_remove"
android:layout_width="67dp"
android:layout_height="67dp"
android:layout_alignParentRight="true"
android:layout_marginTop="400dip"
android:padding="10dip"
android:background="#drawable/ic_close" />
</com.pagesuite.flowtext.FlowTextView>
</LinearLayout>
It probably fails to find your com.pagesuite.flowtext.FlowTextView class.
First check if this class is actually in that package? Did you use a library or copy this class into your own project? If you copied it, you'll need to change the package to the correct value aka point it to your own class.
You got that error just because your xml layout file is not recognise the package com.pagesuite.flowtext.FlowTextView
If you change it to right one then error will not be there.
Feel free to comments.
I wrote the FlowTextView class. The project has had quite a few bug fixes and the JAR file hasn't been updated so I would advise against using the JAR file and check the whole source out and use it as a library project.
This means you get the latest version and it will probbly solve your import issue at the same time.
IF you are not familiar with library projects in eclipse then check this

Add Adwhirl in Dialog causes Inflate Exception

i get an Inflate Exception,
android.view.InflateException: Binary XML file line #76: Error inflating class,
while adding AdWhirl Layout in the XML and set this XML as Content-View of the Dialog, i don't know why this exception is occurring and how to resolve it please guide me to solve this issue, i think following code will help u to diagnose that where problem resides:
This is my XML, where i have added Adwhirl layout:
<LinearLayout
android:id="#+id/LinearLayout04"
android:layout_marginBottom="20dip"
android:gravity="center"
android:layout_height="250dip"
android:layout_gravity="center"
android:layout_width="fill_parent"
>
<com.adwhirl.AdWhirlLayout <!-- Exception occurred on this line-->
android:id="#+id/adwhirl_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
And in the Java Code:
runOnUiThread(new Runnable() {
#Override
public void run() {
isShowed = true;
dialog = new Dialog(getApplicationContext());
dialog.setContentView(R.layout.replay_screen);//Exception occurred on this line
}
});
I have resolved this issue as now i am adding AdWhirl View by Code.

Error inflating class TouchImageView

I'm trying to spruce up my image viewer activity by converting from an ImageView to a TouchImageView, per the answer here: How can I get zoom functionality for images?
However, I get an error when my activity is attempting to load:
Binary XML file line #15: Error inflating class TouchImageView
Here's my image_viewer.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--
<WebView
android:id="#+id/webView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
-->
<TouchImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
And my code inside onCreate of ImageViewer.java (though I'm pretty sure that execution never even gets this far):
if(filepath != null && filepath.length() > 0 && new File(filepath).exists())
{
Bitmap myBitmap = BitmapFactory.decodeFile(filepath);
TouchImageView imgView = (TouchImageView) findViewById(R.id.imageView1);
imgView.setImageBitmap(myBitmap);
}
Any ideas as to why or what is causing this error? What I saw was the inner most exception/cause. Not sure how I can get more details about the error.
Thanks in advance.
UPDATE:
Exception gets thrown on execution of this line:
setContentView(R.layout.image_viewer);
Further detail on the error:
java.lang.ClassNotFoundException: android.view.TouchImageView in
loader dalvik.system.PathClassLoader#44bfde70
You need to have the fully qualified name to any custom view classes. e.g:
<com.kon.thing.TouchImageView ... />
The JVM can't find your class.
make sure u have entered a correct package name in xml
like..
<com.gallery.TouchImageView
android:id="#+id/imgDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter" />

Categories

Resources