Android :: Droid ImageButton - Determine What Resource Is Currently Set?
Jun 30, 2010
Is there a way I can find what resource a particular ImageButton is set to, at any given time?
For eg: I have an ImageButton that I set to R.drawable.btn_on onCreate. Later, at some point, the ImageButton gets set to R.drawable.btn_off. I want to be able to check what resource the ImageButton is set to in my code.
I want to determine a resource string is existing or not. Because other programs in my system will build this string, I need to check the string building is success or not. If fail, I would replace this string as other string. is it possible to check R.build.buildid is existing or not?
What I want to do is a database listview With a small image button and text on the right side The I want the small image to change with a URL given by A text file but I am stuck and the 2 hour rule is up
For(file lenght) So URL is www.site.com/images/(i++).png
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 want to create an Android ImageButton in the xml file with a background image, and a smaller icon on top of that, right in the center. For some reason, it's not obvious how to do it, and documentation is no help.code...
However, no matter what I try (putting "wrap _ content" instead of absolute numbers on layout _ height and layout _ width, the icon remains in the top left corner of the button. If, however, I have no background image (i.e. a system default white button), the icon does go into the center. The button also goes into the top left corner when I use a color instead of an image for the background.
Why does this happen, and how would I actually get the behavior I want-- that is, a background image with the icon in the center?
I have a widget on my home screen with several ImageButtons which have default background images. Through the configuration activity, I can change the image on any of the ImageButtons. The problem is that when the screen is rotated, the image on the ImageButton disapears and it changes back to the default image.
Does anyone know if there is a way to identify (in code, not LogCat) when the GC has run? Perhaps an intent is fired? I could analyze the LogCat output, but it would be ideal if I could determine when the GC has run from my code.
Essentially, I need the contents of TextView 2 to wrap to the next line, but start where TextView 1 starts. I was thinking that if I knew how much text would fit into TextView 2 before it runs out of space on line one, I could take the rest of the text and put it in another TextView below the first two. So I need to measure how much text will fit into a TextView (which can be tricky because as far as I can tell, Android will try to break the text in a TextView at a good location so that it won't break a word in the middle if it can be avoided) or I need a new idea on how to lay this out.
I know how to get the API level, android.os.Build.VERSION.SDK_INT, but there are also several revisions of each level release, e.g. for 2.1 there's rev 1 and 2. How do I determine the revision of a build?
The reason i'd like to know this is that I have a workaround for a bug in Android 2.1 (and 2.2), and this workaround will break the moment the corresponding bug is fixed. So right now i'm in the odd position of hoping that the bug won't be fixed (at least not until I can find an answer to above question).
Is there any way to determine programmatically the time at which an Android application was installed? I don't see anything in PackageInfo, etc.
--EDIT-- To clarify, App A is installed at Time X. At some later time, Time Y, App B is installed. Is there any way App B can know when App A was installed? The link http://stackoverflow.com/questions/2831333/how-to-get-app-install-time-from-android/2920310#2920310 indicates that reading the modify time on the source dir of the App is sufficient. Is this really correct? Why?
How does Android determine whether to move the layout up when showing the softkeyboard?
Note: I am aware that the activity property android:windowSoftInputMode="adjustResize|adjustResize|adjustUnspecified" exists, as described here http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft , but in my case it doesn't seem to have any effect. This is my problem:
I have two activities, pretty much the same layout, but the first one is using a ListView that holds a list of buttons. The second activity holds a scrollview with buttons. The rest is the same, same number of buttons, same height of elements, etc.
Now, when I press the search button to open the search input bar, in my first activity, the entire layouts gets moved up. While on the second activity, the layout is not being moved up but the softkeyboard just displays on top of it. This is actually how I want it to behave. How can I achieve the same with my activity that's using the ListView?
In my manifest, initially I didn't specify any android:windowSoftInputMode attribute, but even if I do, it doesn't make any difference; I tried all three values (adjustPan, adjustResize, adjustUndefined, without any difference).
This is my layout:
Interestingly though: when I set my ListView visibility in my layout 1 (left) to View.INVISIBLE, then the layout doesn not get moved up!
I'm trying to programmatically determine what audio applications are installed on an Android phone. I'm able to enumerate all the installed applications, but don't yet see a way to figure out which ones are capable of playing audio? What property of the application would have to queried to determine if is capable of playing audio?
The typical method to obtain signal strength has been to extend the PhoneStateListener class and override the onSignalStrengthsChanged method. Anytime the signal strength changes the system will call this method passing in the new ASU.
Since this method is now deprecated as of Android 2.0, how are we suppose to go about obtaining the signal strength? I tried using the method above on Droid (CDMA) and the ASU passed in is always -1.
There are also no details in the SDK as to why this was removed or what we are supposed to do now. http://developer.android.com/reference/android/telephony/PhoneStateLi...
1.) As normally the database stored in internal memory, can we specify the path of external storage and use it in similar way ? 2.) How to determine the size of available space of database ? I used getMaximumSize() from SQLIteDatabase class but that gives me 1099511626752 Is this in bytes ? If assumed then this seems to be too large and not practical. I am using HTC G1 to test this. 3.) How can I determine the size of an entry in table ? Or do I have to pull the whole table and manually see its size. Is it same that would be in phone storage ? 4.) Can I check if any free space available before making entry in database ? I want to prevent SQLiteFullException.
I am buiding an Android app, and I have a problem to get resource from string.xml. I need to have an URL in String.xml that will be used several times through the app. I tried Resources.getText("my_url"), but this does not work. Eclipse complains when I use this. Do you think this is the best way to do ?
Is there any way to have an html file (i.e. an html template) be a resource in android? I'd like to reference it in a similar way that i store strings in the res/values/strings.xml. However, when i do this, it appears the HTML is not getting rendered correctly when i use code...
My application will have some customisation for each company that uses it. Up until now, I have been loading images and strings from resource files. The idea is that the default resources will be distributed with the application and company specific resources will be loaded from our server after they click on a link from an email to launch the initialisation intent. Does anyone know how to replace resource files? I would really like to keep using resource files to avoid rewriting a lot of code/XML. I would distribute the application from our own server, rather than through the app store, so that we could have one version per company, but unfortunately this will give quite nasty security warnings that would concern our customers.