Tag: xml

How to insert “<<” text in TextView?

I need to insert “<<” in android:text = “<<” but there are raise problem with: Multiple annotations found at this line: – [I18N] Hardcoded string “<<“, should use @string resource – The value of attribute “android:text” associated with an element type “Button” must not contain the ‘<‘ character. Can you tell me how can I […]

CardView has lost margin when inflating

In my activity, I am setting the layout activity_main onCreate. I am then wanting to inflate my CardView for each of the items in my array. So far, I’ve got everything loaded, however my CardView’s have lost their margin. When added to the layout through XML, the margin works, but when its inflated as a […]

How to preserve line breaks in xml <string> resources in Android?

I’m trying to use multi-line constants (defined in .xml file under /res/values/ folder), but it seems it’s impossible to preserve line breaks there – they all being converted in spaces. I’ve tried to play with “formatted” attribute of strings (setting it both to “true” and “false”, also I’ve tried wrapping strings in CDATA tags, like […]

xml pull parser assets xml

How can i parse a local XML file in the assets folder using pull parser? I can’t get pull parser to work. It always throws an io exception. I think I can’t get the path to the file, or connecting to the file.

InvocationTargetException on inflating an xml – android

I have a code that works 99% of the time since is deploy in lots of clients, but sometimes I get the following: java.lang.reflect.InvocationTargetException android.widget.LinearLayout.(LinearLayout.java:92) java.lang.reflect.Constructor.constructNative(Native Method) java.lang.reflect.Constructor.newInstance(Constructor.java:446) android.view.LayoutInflater.createView(LayoutInflater.java:499) com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562) android.view.LayoutInflater.rInflate(LayoutInflater.java:617) android.view.LayoutInflater.inflate(LayoutInflater.java:407) android.view.LayoutInflater.inflate(LayoutInflater.java:320) com.mycode.mycode.MyClass.draw(xxxxxxx) ….. and on my code I have: LayoutInflater li = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); theview = li.inflate(R.layout.partofthescreen, somecontainer, false); so the […]

Evenly spaced button in Layout

I’m trying to make 4 buttons, evenly spaced in a portrait view on Android. The space should scale up and down depending on the screen size, with an even amount of space between each button and the borders. I tried using linear layout, weight and layout gravity but it seems that I cannot center the […]

If ScrollView only supports one direct child, how am I supposed to make a whole layout scrollable?

I have 3 text views in a layout, where the text clips a tad on the bottom on my droid 2…hhow can I ensure that the whole text is viewable and the user can scroll down (simply with their finger) to see the rest of my text? Thanks! EDIT: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” […]

Android development – 'missing theme error' in eclipse ide for layout xml files

I have recently installed Eclipse IDE for Java Developers (Version: 3.6.1) with the Android SDK Platform 2.1update1 – on Windows 7. I can add, edit and run code for projects, however, in the Workbench area the Graphical Layout view of the layout xml files always shows a “missing theme” message in bottom right navigation area.The […]

match_parent not working for ListView, if ListView is inside NestedScrollView

In my app I am using a ListView and it is inside a NestedScrollView. When I set height of the ListView to match_parent it does not cover the whole screen. I want that ListView to cover the whole screen. My XML file: <?xml version=”1.0″ encoding=”utf-8″?> <android.support.v4.widget.NestedScrollView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:isScrollContainer=”false” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_gravity=”fill_vertical” android:clipToPadding=”false” app:layout_behavior=”@string/appbar_scrolling_view_behavior”> <LinearLayout […]

Adding spinner to ActionBar (not Navigation

I have added a spinner to my ActionBar using the second option from the answer here . How to I add a spinner adapter to the spinner? I tried using a Spinner object as Google describes here but get a null Spinner object. Anybody know how to do this? I don’t want the spinner to […]

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