4.1: XML Layout LinkedHashMap error - android

<?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="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Some Text"
android:layout_margin="5dp"
android:textSize="22sp"
/>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#android:color/black"
/>
<EditText
android:id="#+id/edit_firstname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text"
/>
</LinearLayout>
</LinearLayout>
I have this XML Layout above, everything is working fine in 4.0.3, but when I apply it to 4.1, it produces this error below. When I removed EditText layout is fine.

Dont know the reason but placing android:inputType="textNoSuggestions" in EditText is working.

It's an issue right now It doesn’t come from ADT 20 but from the rendering library of Jelly Bean. So We need to wait for an update of JB to have a fix.
But as a workaround, we are able to solve this by disabling the SpellChecker.
java.lang.NoSuchMethodError: java.util.LinkedHashMap.eldest()Ljava/util/Map$Entry;
at android.util.LruCache.trimToSize(LruCache.java:206)
at android.util.LruCache.evictAll(LruCache.java:306)
at android.widget.SpellChecker.resetSession(SpellChecker.java:141)
at android.widget.SpellChecker.setLocale(SpellChecker.java:147)
So add android:inputType="textNoSuggestions" to your EditText and you will get this problem resolved.
For more details see this link.

Related

is not a sibling in the same RelativeLayout

Hello I am starting with Android developing. I am just modifying with ECLIPSE an open source example. I have only modified strings.xml and some .png files. In the Android simulator it works perfect but when I try to generate the signed apk file I receive two errors with similar description. This is one of them (the line is marking with *):
Description #+id/about_us_desc_webview is not a sibling in the same RelativeLayout cc3x_about_us.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#android:style/Theme.Black.NoTitleBar.Fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_background"
android:orientation="vertical" >
<include
android:id="#+id/cc3x_about_header_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/cc3x_headerlayout" />
<TextView
android:id="#+id/about_us_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/cc3x_about_header_view"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/about_title_label_top_margin"
android:text="#string/about_us_label"
android:textColor="#color/grey_text_color"
android:textSize="#dimen/extra_large_text_size"
android:textStyle="bold" />
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="#dimen/min_divider_height"
android:layout_below="#+id/about_us_textview"
android:layout_marginLeft="#dimen/about_title_label_side_margin"
android:layout_marginRight="#dimen/about_title_label_side_margin"
android:background="#drawable/about_page_divline" />
<WebView
android:id="#+id/about_us_desc_webview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/view1"
android:layout_marginLeft="#dimen/about_title_label_side_margin"
android:layout_marginRight="#dimen/about_title_label_side_margin"
android:layout_marginTop="#dimen/min_margin_cutoff" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/about_us_desc_webview" >
<TextView
android:id="#+id/about_screen_contact_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
* android:layout_below="#+id/about_us_desc_webview"
android:layout_centerHorizontal="true"
android:text="#string/contact_label"
android:textColor="#color/grey_text_color"
android:textSize="25dip"
android:textStyle="bold" />
<View
android:id="#+id/divider_bottom"
android:layout_width="match_parent"
android:layout_height="#dimen/min_divider_height"
android:layout_below="#+id/about_screen_contact_label"
android:layout_marginLeft="#dimen/about_title_label_side_margin"
android:layout_marginRight="#dimen/about_title_label_side_margin"
android:background="#drawable/about_page_divline" />
<TextView
android:id="#+id/about_xcube_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/divider_bottom"
android:layout_margin="#dimen/max_margin_size"
android:autoLink="web"
android:text="#string/xcube_url"
android:textColor="#color/blue_text_color"
android:textColorLink="#color/blue_text_color"
android:textSize="10dip" />
<TextView
android:id="#+id/about_xcube_contact_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/divider_bottom"
android:layout_margin="#dimen/max_margin_size"
android:autoLink="email"
android:text="#string/xcube_contact_email"
android:textSize="#dimen/small_text_height" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/about_xcube_link"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="#string/about_xcube_address"
android:textColor="#color/grey_text_color"
android:textSize="#dimen/small_text_height" />
</RelativeLayout>
</RelativeLayout>
Any help will be apreciated. Thank you very much!!
The line
android:layout_below="#+id/about_us_desc_webview"
in your TextView is redundant. Since the RelativeLayout already has that attribute, it is useless. You can just erase that line and nothing should change.
And the reason it generates error is that, you can apply features such as below, above.. etc with an element in the same layout. Here "about_us_desc_webview" is out of the RelativeLayout and you cannot position something inside a RelativeLayout with something outside a RelativeLayout.
android:layout_below
Positions the top edge of this view below the given anchor view ID .
When Arise
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:id="#+id/rl_rootHeader"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/rl_Header"
android:layout_below="#+id/rl_rootHeader" // Arise ,In here RelativeLayout is Parent .
>
//
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:fillViewport="true"
android:id="#+id/scrollRoot"
android:background="#color/colorWhite"
>
</ScrollView>
Right Way
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:id="#+id/rl_rootHeader"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/rl_Header"
>
//
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:fillViewport="true"
android:id="#+id/scrollRoot"
android:background="#color/colorWhite"
android:layout_below="#+id/rl_rootHeader" // Call Here .This section is Child
>
</ScrollView>
In my case, The problem was with Kotlin Version. I updated the the Kotlin version and the problem "is not a sibling in the same RelativeLayout" resolved
Just remove the lines which are causing error from layout
.xml file
Try refreshing the layout
Your layout will probably change. You can now reset it properly.
If you go to Properties Panel you will see layout:alignComponent has some alignment shown as "Not Found". Just clear it out. In the above example Properties window -> textview -> layout:alignComponent check all alignment values.

Difference in android layout designs between versions 2.3.3 and 4+

I'm facing a strange issue in my project when creating a simple xml design as follow:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#FF0000"
android:layout_marginLeft="30dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button"
android:layout_gravity="left|center_vertical"/>
Now see the difference, this is the view in 4.2.2 :
And this one in 2.3.3:
Would appreciate if someone can help me with it. thanks
It works, if you change it to this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:background="#FF0000"
android:orientation="vertical" >
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="New Button" />
</LinearLayout>
(I think I know why it behaves like this, let me just check something. I'll add an explanation later on)
I have faced the same issue, in my case I had something like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/match"
android:background="#color/light"
android:orientation="vertical"
android:layout_margin="#dimen/lateral_margin" >
<ImageView
android:id="#+id/full_screen_image"
style="#style/match_width"
android:scaleType="fitCenter"
android:layout_gravity="center"
android:layout_weight="2"
android:contentDescription="#string/image_content_description"/>
<TextView
android:id="#+id/barcode_number"
style="#style/match_width"
android:gravity="center"
android:textColor="#color/dark_text"
android:textSize="30sp"
android:visibility="gone" />
</LinearLayout>
My problem was solved changing
android:layout_margin="#dimen/lateral_margin" >
with:
android:padding="#dimen/lateral_margin" >
It seems androids 2.3.3 and lower were computing the margin differently than android 4 and greater. Now all of them behave the same way.
In your case, maybe setting the black layouts margin as padding could help.

XML UI not displaying correctly on android - button and text input not displaying

I have just started reading into android development so I am willing to bet there is a very simple solution to this..
I followed the guide on the Android developer site, building the sample UI. The graphical layout shows the button and text input box no problem so it does not seem to be an issue with the code. For some reason it does not display on the AVT or when I install the APK on a phone... I am using a Galaxy Nexus and set up the AVT as a Galaxy Nexus too.
I have updated the ADT and tried several things but I am assuming there is something I have maybe forgotten to configure? can someone help?
Im new to this so be nice ;)
here is the xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
Thanks in advance
<LinearLayout 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:orientation="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
also please check if you have called setcontentview function in your activity passing this xml layout

android soft keyboard covers editText in landscape

I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_above="#+id/edittext">
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="line1"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="line2"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="line3"/>
</LinearLayout>
<EditText
android:id="#id/edittext"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_margin="5dp"
android:text="test"
android:layout_alignParentBottom="true"
android:imeOptions="flagNoExtractUi"
/>
</RelativeLayout>
and in landscape on a Nexus one it looks like:
Is there a way to fix this, but keep flag flagNoExtractUi ?
Define <activity> inside Android manifest like:
<activity android:name=".TodoEdit"
android:windowSoftInputMode="adjustResize">
You can add a ScrollView so that when appears the keyboard, it scrolls automatically to make the view fully visible.
It seems to be a bug in Android but I found a solution! Just replace android:imeOptions="flagNoExtractUi" with android:imeOptions="flagNoFullscreen" and everything will work now.

Adding a ListView causes the Android App to crash

I have a problem which seems to weird.
The Android application I created is running fine, but when I added a "ListView" element in my layout.xml file.
and I still haven't used the ListView in my java class the application refuses to startup.
It simply craches and gives me this Msg : The application Client (process com.example) has stopped unexpectedly. Please try again.
This is my layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="#+id/view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/filename"/>
<ListView android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
/>
<EditText
android:id="#+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
/>
<Button
android:id="#+id/connect"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Connect"
android:onClick="Connect"
/>
<Button
android:id="#+id/download"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Download"
android:onClick="Download"
/>
<Button
android:id="#+id/delete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="List"
android:onClick="List"
/>
</LinearLayout>
Note: I'm testing on an Android device and not the emulator
Here is a Screenshot of the error I get in logcat: http://img852.imageshack.us/i/screenshotgg.png/
And finally found the sill mistake which caused it not to work
I declared 2 widgets with the same id.
Thnx alot in advance.
You need to close the LinearLayout. Add </LinearLayout> to the end of the xml.
Edit: I see that you've uploaded the log. The problem is in your onCreate-method on line 42. Please post this method.

Categories

Resources