android-xml

How to parse same name tag in Android XML DOM Parsing

核能气质少年 提交于 2019-11-26 18:01:46
I am not able to parse my XML here.It returns "Item" only. My AndroidActivity cannot be shown as it is very big that's why i have only shown the part which is responsible for parsing. My XML Looks like this : <MyResource> <Item>First</Item> <Item>Second</Item> </MyResource> My ActivityClass method: public class ShowItems extends Activity{ ListView lv; ListAdapter adapter; static final String KEY_RESOURCE = "MyResource"; // parent node static final String KEY_ITEM = "Item"; ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); String[] from={KEY_ITEM }; int[] to=

format statement in a string resource file

╄→гoц情女王★ 提交于 2019-11-26 17:34:38
问题 I have strings defined in the usual strings.xml Resource file like this: <string name="hello_world"> HELLO</string> Is it possible to define format strings such as the one below result_str = String.format("Amount: %.2f for %d days ", var1, var2); in the strings.xml resource file? I tried escaping the special characters but its not working. 回答1: You do not need to use formatted="false" in your XML. You just need to use fully qualified string format markers - %[POSITION]$[TYPE] (where [POSITION

Heterogeneous GridLayout

感情迁移 提交于 2019-11-26 17:10:22
UPDATE - my working solution: https://stackoverflow.com/a/21233824/902172 I am trying to implement the layout below: I guess GridLayout is suitable for my needs but after 2 hours of struggle I couldn't create even a similar layout.. The layout is resizing itself wrongly , it exceeds the screen of the phone and it also does not span the specified rows and columns. Here I selected a button so you can see how it exceeds the boundaries: and here is the associated xml code: https://gist.github.com/2834492 I have reached a similar layout with nested linearlayouts but it's not possible to properly

How do you create Preference Activity and Preference Fragment on Android?

十年热恋 提交于 2019-11-26 15:54:15
As I was following an old tutorial ( Créez des applications pour Android -> openclassroom ) I got stuck on this deprecated method addPreferencesFromResource(int id) from the PreferenceActivity class. So my question is : What is the new way of creating Preferences in Android ? WannaGetHigh I found this post ( What to use instead of “addPreferencesFromResource” in a PreferenceActivity? ) that help me understand that you have to go through a PreferenceFragment in order to do it. In the following explanation I use your.package. just to show that you have to put the package name. Everybody has its

Activity Layout: Fragment class: vs android:name attributes

自作多情 提交于 2019-11-26 15:18:04
I've read the documentation about Fragments in the Android Developer Guide and I've seen that sometimes they specify the class to instantiate with the Fragment tag attribute android:name and sometime they use the class: attribute: <fragment android:name="com.example.news.ArticleReaderFragment" android:id="@+id/viewer" android:layout_weight="2" android:layout_width="0dp" android:layout_height="match_parent" /> <fragment class="com.example.android.apis.app.FragmentLayout$TitlesFragment" android:id="@+id/titles" android:layout_weight="1" android:layout_width="0px" android:layout_height="match

How can you get the Manifest Version number from the App&#39;s (Layout) XML variables?

回眸只為那壹抹淺笑 提交于 2019-11-26 15:06:40
问题 I would like to have a way to reference the project's manifest version number in the main part of the code. What I have been doing up until now is to link the version number in a String XML file to the manifest (@string/Version). What I would like to do is to do it the other way around, link a string XML variable to the version in the manifest. The reason? I'd like to only have to change the version number in one location, the manifest file. Is there any way to do this? Thanks! 回答1: I believe

How do I clear ListView selection?

一世执手 提交于 2019-11-26 14:29:57
问题 TL;DR: You choose an option from (a) my listview. Then, you change your mind and type something in (b) my edit text. How do I clear your listview selection and only show your edittext? (and vice versa) I have an application with a listview of options as well as an edittext to create an own option. I need the user to either choose or create an option, but not both. Here's a drawing of my layout: Whenever the user selects an option from the listview, I set it as "selected" by making it green,

How to combine BottomAppBar + FAB with BottomNavigationView

这一生的挚爱 提交于 2019-11-26 11:18:17
问题 I want to use the FloatingActionButton , along with its behaviour when anchored on a BottomAppBar, on top of a BottomNavigationView. I came up with a rather \"hacky\" trick to just place the BottomNavigationView on top of the BottomAppBar without providing a background thus making it transparent. This seemed to work well at first sight but I found out that the fab button can only be clicked when touching the upper half of the button (So where there is no transparent BottomNavigationView on

Unexpected namespace prefix “xmlns” found for tag LinearLayout

蹲街弑〆低调 提交于 2019-11-26 11:06:34
问题 I am having an error in following xml file. \"Unexpected namespace prefix \"xmlns\" found for tag LinearLayout\" . I tried the solutions provided in other similar questions also but it didn\'t work for me. Same error is occurring in 3 lines where LinearLayout is used. <?xml version=\"1.0\" encoding=\"utf-8\"?> <ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\" android:layout_width=\"fill_parent\" android:layout_height=\"wrap_content\" android:background=\"@drawable

Custom designing EditText

强颜欢笑 提交于 2019-11-26 10:15:53
问题 I have custom designed EditText search_page.xml <LinearLayout android:layout_width=\"fill_parent\" android:layout_height=\"wrap_content\" android:orientation=\"horizontal\" android:padding=\"10dp\" android:background=\"#E1E1E1\" android:weightSum=\"1\" > <TextView android:layout_width=\"0dp\" android:layout_height=\"wrap_content\" android:layout_weight=\".25\" android:text=\"City\" /> <EditText android:layout_width=\"0dp\" android:layout_height=\"wrap_content\" android:layout_marginLeft=\