Tag: xml

Can't get array string resource from XML

I have a list of values in my XML file which I would like to select based off a spinner selection. For some reason, using an array-string for the spinner works fine, the values are populated into the spinner. For whatever reason, I cannot get the values of the second array to save my life, […]

How to set menu to Toolbar in Android

I want use ToolBar instead of ActionBar, but don’t show me menu in toolbar!!! i want set menu such as Refresh or Setting buttons in ActionBar. Please show this link for my problem image : Image Link Toolbar.xml code : <?xml version=”1.0″ encoding=”utf-8″?> <android.support.v7.widget.Toolbar xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”?attr/colorPrimary” android:minHeight=”?attr/actionBarSize” app:navigationContentDescription=”@string/abc_action_bar_up_description” app:popupTheme=”@style/ThemeOverlay.AppCompat.Light” app:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar” app:title=”Main Page” […]

ERROR:The processing instruction target matching “” is not allowed

This question already has an answer here: Error: The processing instruction target matching “[xX][mM][lL]” is not allowed 2 answers

Parsing local XML file using Sax in Android

Can anyone tell me how to parse a local XML file stored in the system using SAX, with an example code? Please also tell me where can I find information on that.

Android adding footer to ListView addFooterView()?

I have a ListView activity that needs a footer to the list of items so that you can click it and it would load more items into the list. The list is backed my an SimpleAdapter backed by a map of strings and before the adapter is set i do this inorder to add the […]

CardView goes on top of FrameLayout, but declared first

I have simple FrameLayout with support CardView as first item, and TextView as second, so TextView must be on top of inflated view. This works on pre-Lolipop but on 21+ card takes toppest place in layout, why that’s so and how to fix this? Same thing with RelativeLayout. Layout: <?xml version=”1.0″ encoding=”utf-8″?> <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” […]

what's wrong with hardcoded string in android xml file?

I love to put simple text directly on the xml file without declaring a string first. It is easier, more simple and less messy. However, it always has a warning badge whenever I do so. What if I have a dozens of hardcoded string in my xml file without concerning the warning? Will I get […]

RadioGroup checkedButton property

I am trying to build RadioGroup in Android with one RadioButton checked by default. I’m wondering if this is possible to do through XML, rather than programmatically. The following code snippet doesn’t seem to work as I’m getting an error: error: Error: No resource found that matches the given name (at ‘checkedButton’ with value ‘@id/rdb_positive’) […]

Android layout with square buttons

I want to make a layout similar to this one: www.ImageBanana.net – layout.png http://www.imagebanana.com/img/9kmlhy66/thumb/layout.png Four square buttons on the screen – each of those using half of the screen with/screen height (whichever is smaler). Independent of screen size/resolution. I already tried to achieve this by using a LinearLayoutbut the buttons are ending up using the […]

Should use “sp” instead of “dp” for text sizes

When I use android:textSizes=”20dp” in my XML for a textView, I got a warning “Should use “sp” instead of “dp” for text sizes.” Why should “dp” not be used? What is the correct approach? How can I achieve same textsizes on different displays?

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.