I'm trying to find a way to open resources which name is determined at runtime only. Let me explain in more details. I want to have a XML that references a bunch of other XML files in the application apk. for the purpose of explaining lets say the main XML is main.xml and the other XML are file1.xml file2.xml...fileX.xml...
what i want is to read main.xml, extract the name of the xml I want (fileX.xml) for example. and then read fileX.XML. the problem I face is that what I extract form main.xml is a string and I can't find a way to change that to R.raw.nameOfTheFile
I'm dealing with a problem you guys might not have faced earlier. I'm having a use-case in my Android application where the actual screen that I want to show to user is not stored in any layout file of my application. The layout of the of the screen is designed by server in this case, based on selection made by user on first screen.
Let me elaborate here, 1st Screen : List of check box with different biller names. (Imagine I've selected 2 billers from this screen) 2nd Screen : (The screen that server has decided how it should look like) * Header, * 1st Biller name (Label) * Amount for 1st Biller TextBox * Image (a Separator image) * 2st Biller name (Label) * Amount for 2st Biller TextBox. * Here there can be a checbox/radio/another TextBox anything. * Image (a Separator image) * Button (to submit above form back to server)
I hope makes some sense in what I'm planning to design. The current issues I'm dealing with are as below. 1). How to draw this dynamic widgets? 2). How to fetch user Inputs from this dynamically created widgets?
I would like to make a single Android app for multiple Android versions (possibly every one of them) My problem is that I want to check what is the version of Android the app is currently running on, and dynamically load a class which is version dependent. This part should be ok.
I just wonder how I can achieve that without compilation errors in my Eclipse project. I mean, the project is configured for a particular target (1.5, 2.1 ...), so if a class in my project is not compatible wich the selected target, it will result in errors.
Is there a way to export this classes even if they are not fit for the platform (I thought about a separated lib, but then again : how to compile theses classes into a lib without compilation pbs?) ? This should be ok since they won't be loaded until I ask them to after having checked Android version.
I am developing an application. In that application i have 2 list view (a and b ), i need to load the content of the list view (b) according with the selected value of first list view(a).How its possible.
What I want to do is make some changes to the bitmap before It gets drawn to the main canvas in my draw method (As it would seem wasteful to repeat lots of drawing in my main loop when it isn't going to change). I am making the changes to the bitmap with the following:
Canvas c = new Canvas(mBackground); c.drawARGB(...); // etc
So naturally I get an exception
java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor
So to avoid that I made a copy of the bitmap so that it is mutable
No exception is thrown, but returned TypedArray array has nothing valuable inside it. At least I couldn't find anything that is connected to actual resource id or resource I'm interested in.So, how to load resources represented by android.R.attr.* ids?
I use this method couples of occasion to load text file to display as help file. But I don't know why the following code didn't work. It seems to hang and logcat says "OutOfMemoryError"? All I did was break this out as an separate activity.
Are there any Android phones that are multi-processor (multi-core/ cpu), where application threads execute concurrently on different processors?
There doesn't seem to be any explicit way of doing asynchronous file I/ O or asynchronous resource loading. So, suppose I put BitmapFactory.decodeResource() or Resources.openRawResource() into a separate thread. Will those methods play nice with the other threads, yielding during blocking I/O operations so those other threads can run?
If those methods rely on the thread scheduler to forcibly suspend them, then the separate resource-loading thread isn't going to help me get my application started any faster (although it will help it to be more responsive to user input).
I have an XML resource file: <resources> <section> <category value="1" resourceId="@xml/categoryData1" /> <category value="2" resourceId="@xml/categoryData2" /> <category value="3" resourceId="@xml/categoryData3" /> </section> </resources> Using XmlPullParser, on the START_TAG, I can use: int value = parser.getAttributeIntValue(null, "value", 0); to get values 1, 2, 3...however: int resourceId = parser.getAttributeIntValue(null, "resourceId", 0); doesn't work...it just yields the default value 0, or whatever I change the default value (3rd parameter) to be. Does anyone know what I am doing wrong or if this is possible?
I've looked through the documentation and I can't seem to figure out how to have the screen blured/greyed when I select an activity that may take a while to load.
This seems to be an Android standard (both the Camera app and the Camcorder app do it when first selected), but I don't see any documentation on it. I even tried looking through the source of these apps on git, but couldn't seem to find it.
I am new to this android stuff and SQLlite etc.I am going to log some numbers at a certain interval, and will put them into a dynamic histogram, by dynamic i mean that there will be a maximum number of samples in the histogram, the histogram and age stuff should be persisted either in db or plain file.For simplicity, I would like the samples to be stored in a blob type datafield, but i cannot se if this is possible. Alternative i could have another table with the samples Or I could simply have files with filename = name and content = samples.my concern might be unclear by now, but put simply, what is most effecient regarding power usage?
I define once in my /xml/widget.xml the minwidth. but what can i do when I need to inflate different sizes from my widget layouts for 1 one my 3 widgets thats fine, but the last 2 widgets would just need one icon size, so they always need the width of 2 icons. also when I make minwidth smaller.. it fits with the other 2 widgets but the large widget come cutted.How to solve that. I cant believe to create a total new receiver and a new /xml/widget2.xml just for another size?!
I want to create a TextView that will stretch the width of the screen and use a textsize that will keep the text on one line and fill the width. So bigger words would be smaller fontsize and smaller words would be bigger font size. I tried digging around in the docs under TextView but could not find what I needed.
I need a gallery to be able to hold up to thirty custom views. These views need to added or removed whenever, they also need to be able to be display in a display bow beneath the gallery. How do I do this?I looked at the doc file for arrayadapter but it requires me to use a reference Id for each view I add, but each view is all java coded. Should I just use setId upon creation of the view and just throw that id into the array adapter, or is there a way to create one without using resource id's?
I'm trying make a View that divide the screen in three sections. The first section should be 200dip high, the third section should be 50 dip high and the middle section should take the remaining place in the middle. Is there any way to implement it? I tried some ways but either it doesn't work or the app crashed.
I've been reading the (shoddy) documentation for the Google Maps API (MapActivity et al), and I think I have roughly worked out how it works. It seems that if you want to add a marker overlay you can use ItemizedOverlay easily, but you have to add all your markers at once. There doesn't seem to be any way to remove them.
What I want to do is query markers from an online database as the user pans around (in the same way the actual map tiles are fetched). Is there a simple way to do this?
As far as I can tell I need to subclass Overlay and implement the draw method, but where is the best place to put the code that fetches new markers when the map is panned? There doesn't seem to be an onMapChanged() method anywhere. My best guess is MapController.onKey() but that seems wrong.
I want to put a ListPreference in my preference screen. But all the examples I have found in Internet the content are loaded out of a xml and I need that de options in the ListPreference are dynamic and not previously defined (in a xml).
I have mi preferences.xml in the folder xml/ of my project; this is the code of preferences.xml: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android
I'd like to use different row descriptors (from the XML layout resource) in one ListView. Can I and how? Also, I'd like to be able to programmatically change the size of the rows, based on the data in each row, in a ListView. Can I and how?
My customRelativeLayout at the bottom of the XML has a XML layout too:
What I want to do: I want to be able to change the position of my CustomRelativeLayout. It should be follow my touch. Its smaller than the SurfaceView and should "slide" above following my touch...
There are two problems:
The onTouchListener bind to mLinearLayout (in CustomRelativeLayout) is only triggered once and only for ACTION_DOWN. I see the log output only once The note never changes the position, it is never redrawn with the changed matrix... I see the output stated in onDraw never after the touch happened.
First might be because the SurfaceView also handles touch events. But I thought if the CustomRelativeLayout handles it first, it should work.
Thanks to Xil3 I was able to remove the wall I was run into...
Here is my solution:
My note xml:
And here is my constructor:
I also found a bug/feature/issue, which is absolutely new for me: When I remove the background in my note root element (which is currently transparent) the note is only visible within the 200dp width/height I have set in the inner LinearLayout. So its not fill_parent, its wrap_content even as I set it to fill_parent. So layout_width and layout_height only use the given fill_parent when a background is set...
Is it possible to create just one class and use a variable for contentview? I am thinking of creating a main layout with loads of buttons with IDs. Once a button is pressed it'll then pass the ID to the class and use that ID to open a specific Layout. One class, multiple layouts. code...
I have created a table with 2 rows in it. Each row has 5 TextViews with a default text of 0. There is also a button outside of the table. I am trying to figure out how to update each of the TextViews in each row on each successive press of the button. So on the first press of the button the first TextView in the first row should update to 1. On the second press of the button the second TextView in the first row should update to 2...etc. I can't figure out how to do this programmatically without having to code it all - is it possible? Basically I guess I need to build up the ID of the TextView dynamically. So if the TextViews have ids as item1, item2, item3 etc. Then I need to build up the findViewById(R.id.item + i); Obviously this is not possible but is there a way to do this?
Is it possible to dynamically load classes from a URL into your application in the same way as a desktop application can? For example, can you do a simple boot-strap application which you install onto the device, that boots up loads the main jars required for the applications from a server, or from a local jar on the SD for example?