Android :: Drawable Resource Loaded To Memory?
Oct 19, 2010
Does all resource (all in res folder if on eclipse IDE), specially drawable image, is loaded to memory during runtime? Or it is just like a file which is available when the application need it?
View 1 Replies
Nov 14, 2010
I have created multiple bitmaps - one for each folder (mdpi, hdpi, ldpi). Can someone show me some code or point me to the appropriate method that will allow me to detect which resource Android decided to load.
View 4 Replies
View Related
Oct 10, 2009
I need to use some inbuild drawable I found in
http://developer.android.com/reference/android/R.drawable.html
I set drawable @drawable/ic_input_add to a button in my layout xml file. The add icon appears on the button of layout editor. But there is a error of that xml file said that
Description Resource Path Location Type ERROR Error: No resource found that matches the given name (at 'drawableLeft' with value '@drawable/ic_input_add'). spend_list.xml / AccountBook/res/layout line 5 Android AAPT Problem. How to use a inbuild drawable?
View 3 Replies
View Related
Aug 21, 2009
I have some image names stored in a database, but the images themselves are in the /res/drawable folder of the application. I need to assign these images to some views at runtime, and I'm currently doing it this way:
// public static final String DRAWABLES_PATH = ":drawable/";
int resId = getResources().getIdentifier(packageName+DRAWABLES_PATH +imageName,null,null); mButtonX.setBackgroundResource(resId); //
Is there a more efficient way to do it? Or should I be storing the images directly in the database (they are many)?
View 2 Replies
View Related
Dec 17, 2009
I need to create a tiled drawable using BitmapDrawable but I need to create it from xml resource rather than code.
View 3 Replies
View Related
May 13, 2010
I would like to get a byte array from an jpeg image located in my res/drawable file?
View 3 Replies
View Related
Feb 28, 2010
I have:
String uri = "@drawable/myresource.png";
How can I load that in ImageView? this.setImageDrawable?
View 2 Replies
View Related
May 2, 2010
I am trying to create a drawable in code and change the color based on some criteria. When I try and set the Drawable as the background of the ImageView it displays but won't let me set any padding. I realized I need to set the ImageView image via the setImageDrawable() function in order to be able to set the padding. The problem I am running into is that when I set it via the setImageDrawable() function nothing is displayed.
Here is what I have written:
<?xml version="1.0" encoding="utf-8"?>
ImageView icon = (ImageView) row.findViewById(R.id.icon);
ShapeDrawable mDrawable; int x = 0; int y = 0;
int width = 50; int height = 50;
float[] outerR = new float[] { 12, 12, 12, 12, 12, 12, 12, 12 };
mDrawable = new ShapeDrawable(new RoundRectShape(outerR, null, null));
mDrawable.setBounds(x, y+height, x + width, y);
switch(position){ case 0: mDrawable.getPaint().setColor(0xffff0000); //Red break;
case 1: mDrawable.getPaint().setColor(0xffff0000); //Red break;
case 2: mDrawable.getPaint().setColor(0xff00c000); //Green break;
case 3: mDrawable.getPaint().setColor(0xff00c000); //Green break;
case 4: mDrawable.getPaint().setColor(0xff0000ff); //Blue break;
case 5: mDrawable.getPaint().setColor(0xff0000ff); //Blue break;
case 6: mDrawable.getPaint().setColor(0xff696969); //Gray break;
case 7: mDrawable.getPaint().setColor(0xff696969); //Gray break;
case 8: mDrawable.getPaint().setColor(0xffffff00); //Yellow break;
case 9: mDrawable.getPaint().setColor(0xff8b4513); //Brown break;
case 10: mDrawable.getPaint().setColor(0xff8b4513); //Brown break;
case 11: mDrawable.getPaint().setColor(0xff8b4513); //Brown break;
case 12: mDrawable.getPaint().setColor(0xffa020f0); //Purple break;
case 13: mDrawable.getPaint().setColor(0xffff0000); //Red break;
case 14: mDrawable.getPaint().setColor(0xffffd700); //Gold break;
case 15: mDrawable.getPaint().setColor(0xffff6600); //Orange break;
} icon.setImageDrawable(mDrawable); icon.setPadding(5, 5, 5, 5);
This results in a space for the ImageView but no image.
View 1 Replies
View Related
Aug 18, 2009
I tried doing a ProgressBar and I wanted to change the background and the progress bar using my own drawables from the drawable resource. Is this possible? I just don't want to spend time creating my own custom component if can be done relatively easy.
View 4 Replies
View Related
Nov 2, 2010
I'm going to be using
setBackgroundResource(R.drawable.background)
in my onCreate() method.
When I create the XML file with the and its colors, what type of resource am I creating? "values", "layout"?
View 1 Replies
View Related
May 28, 2010
Can I have sub-folders to hold my drawable resources. For example can I store an image in, say, 'res/drawable/content/images/myimage.jpg' and then find that resource via a call to:
id = context.getResources().getIdentifier("com.mycompany.myprog:drawable/ content/images/myimage", null, null);
I have tried this and it doesn't seem to be working (but I may have something wrong). Is it supposed to work or do all the resources need to be in the root drawable folder? Also, are jpeg files supported and drawable resources?
View 5 Replies
View Related
Oct 5, 2009
Is it possible to have subfolders in the /res/drawable directory. I would like my resources to be organized in a tree view and not in a flat dir. If it is possible so how do I reference the resource from the code?
View 3 Replies
View Related
Sep 1, 2010
I have an app with locally stored .jpg files. I would like to be able to send the images (1 at a time, on user interaction) to the Gallery app's activity using an explicit intent.
View 3 Replies
View Related
Feb 3, 2010
I am making an app for Android, in my Activity I need to load an array of about 10000 strings. Loading it from database was slow, so I decided to put it directly into one .java file (as a private field). I have about 20 of these classes containing string arrays and my question is, are all the classes loaded into memory after my application is started? If so the Activity in which I need these strings would be loaded quickly, but the application as a whole would have a slow start...
Is there other way, how to very quickly load an 10000 string array from a file?
UPDATE:
Why I need these strings? My Android app allows you to find "journeys" in Prague's public transit - you choose departure stop, arrival stop and it finds your journey (have a look here). My app has a suggestions feature - you enter leter "c" as your departure stop and a suggestions ListView appears with stops starting with "c". For these suggestions I need the strings. Fetching the suggestions from database is slow (about 400ms on G1).
View 4 Replies
View Related
May 14, 2010
Does anyone know the syntax for an XML file for a single bitmap drawable resource? What I'm looking to do is "alias" a drawable in my app. I have need for the same image with 2 different names, and rather than including the image twice in my res/drawable directory, I'd rather alias it (it's fairly large). In other words, instead of:
res/drawable/name1.png res/drawable/name2.png
I'd like to have:
res/drawable/name1.png res/drawable/name2.xml
where name2.xml looks SOMETHING like this:
<?xml version="1.0" encoding="UTF-8" ?> <bitmap src="@drawable/name1" />
Is this possible? If so, any idea what the syntax should be? I can't find it in the docs, and I've had no luck with trial-and-error.
You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
View 6 Replies
View Related
Nov 24, 2009
I am experiencing a memory / resource leak on a T-Mobile G1 device with my application. I installed the "Task Manager" application from Android market and my memory usage is not monotonically increasing. It stays relatively flat over time. Furthermore, none of the other processes are chewing up tons of memory either (really, I can get into this state with just my app running). I am not experiencing this problem on any of the other Android phones (including Eris, Hero, and Droid).
The interesting thing is that if I kill my application, the phone is *still* very slow and sluggish. The only thing that seems to be able to get me out of this situation is a battery pull. If I run my application for about 3 hours, the phone starts to become very sluggish. Even simple operations like hitting the "home" button take many seconds. I'm not sure what to do at this point and am wondering where I can go from here.
View 3 Replies
View Related
Nov 26, 2009
In my application, user can click on a button and then he can select a picture from his gallery. This image is then displayed.
However, when the user performs 3 or 4 times this operation, the following exception is thrown, due to memory allocation problem code...
Here a sample of my code ...
Is it possible to force object (here the Drawable object) to be released from memory?
View 5 Replies
View Related
Aug 23, 2010
I need to know how he takes drawable object. I'm collecting some ImageView objects in array, they have background images that are rather big in resolution so they take lot of memory...
I have read somewhere that it will automatically create image with resolution that my imageView have, so i think it will take less memory than first one. Please tell me, if i set scaleType property, will it scale that image? Will that help me to save memory?
View 1 Replies
View Related
Sep 15, 2010
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.
---xml---
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/helptab"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/helptext"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</ScrollView>
---code---
import java.io.DataInputStream;
import java.io.IOException; import java.io.InputStream;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Help extends Activity {
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
InputStream iFile = getResources().openRawResource(R.raw.help);
try { TextView helpText = (TextView) findViewById(R.id.helptext);
String strFile = inputStreamToString(iFile);
helpText.setText(strFile);
} catch (Exception e) {
} }
public String inputStreamToString(InputStream is) throws IOException {
StringBuffer sBuffer = new StringBuffer();
DataInputStream dataIO = new DataInputStream(is);
String strLine = "";
while ((strLine = dataIO.readLine()) != "") {
sBuffer.append(strLine + " ");
} dataIO.close();
is.close();
return sBuffer.toString();
}
View 6 Replies
View Related
Jul 18, 2009
I've got an Android app developed, and I'm at the point of a phone app development where everything seems to be working well and you want to declare victory and ship, but you know there just have to be some memory and resource leaks in there; and there's only 16mb of heap on the Android and its apparently surprisingly easy to leak in an Android app.
I've been looking around and so far have only been able to dig up info on 'hprof' and 'traceview' and neither gets a lot of favorable reviews.
What tools or methods have you come across or developed and care to share maybe in an OS project?
View 3 Replies
View Related
Oct 19, 2010
I am running my application in the emulator using a high density skin (like WVGA800). However the ressources in my application are loaded from the drawable- mdpi folder instead of drawable-hdpi ... what else should I do so that android use the correct folder ?
View 4 Replies
View Related
Aug 3, 2010
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?
View 1 Replies
View Related
Apr 13, 2010
I have a huge UI, in which I have about 300 to 500 rows of data (Horizontal Linear Layout), with each row containing 3 to 4 views. If I load all the UI at once, it takes a long time. How best I can display this UI?
View 5 Replies
View Related
Sep 20, 2010
Helloworld tutorial sample builds and runs just fine, except it doesn't show the text (i.e. loads apps). The only thing I see is that Emulator (Target 2.2 API level 8) comes up with just the "Android" in it. and then the emulator shows up a locked up screen in a while. Here is output from the console [2010-09-20 10:36:55 - HelloAndroid] Android Launch! [2010-09-20 10:36:55 - HelloAndroid] adb is running normally. [2010-09-20 10:36:55 - HelloAndroid] Performing com.example.HelloAndroid.HelloAndroid activity launch [2010-09-20 10:36:55 - HelloAndroid] Automatic Target Mode: Preferred AVD 'my_avd' is not available. Launching new emulator. [2010-09-20 10:37:56 - HelloAndroid] WARNING: Application does not specify an API level requirement! [2010-09-20 10:37:56 - HelloAndroid] Device API version is 8 (Android 2.2) [2010-09-20 10:37:56 - HelloAndroid] HOME is up on device 'emulator-5554' [2010-09-20 10:38:23 - HelloAndroid] Uploading HelloAndroid.apk onto device 'emulator-5554' [2010-09-20 10:38:27 - HelloAndroid] Installing HelloAndroid. apk.After I exit the emulator, I get the following errors. [2010-09-20 09:02:24 - DeviceMonitor] Sending jdwp tracking request failed! [2010-09-20 09:38:46 - ddms]null java.lang.NullPointerException at
com.android.ddmlib.JdwpPacket.writeAndConsume(Jdwp Packet.java:213) at com.android.ddmlib.Client.sendAndConsume(Client.ja va:573) at com.android.ddmlib.HandleHello.sendHELO(HandleHell o.java:142) at com.android.ddmlib.HandleHello.sendHelloCommands(H andleHello.java: 65) at com.android.ddmlib.Client.getJdwpPacket(Client.jav a:670) at com.android.ddmlib.MonitorThread.processClientActi vity(MonitorThread.java:317) at com.android.ddmlib.MonitorThread.run(MonitorThread .java:263)
[2010-09-20 09:38:47 - ddms]null java.lang.NullPointerException at com.android.ddmlib.JdwpPacket.writeAndConsume(Jdwp Packet.java:213) at com.android.ddmlib.Client.sendAndConsume(Client.ja va:573) at com.android.ddmlib.HandleHello.sendHELO(HandleHell o.java:142) at com.android.ddmlib.HandleHello.sendHelloCommands(H andleHello.java: 65) at com.android.ddmlib.Client.getJdwpPacket(Client.jav a:670) at com.android.ddmlib.MonitorThread.processClientActi vity(MonitorThread.java:317) at com.android.ddmlib.MonitorThread.run(MonitorThread .java:263)
[2010-09-20 09:50:11 - DeviceMonitor]Sending jdwp tracking request failed! [2010-09-20 09:59:29 - DeviceMonitor]Sending jdwp tracking request failed! [2010-09-20 09:59:31 - Logcat]device not found com.android.ddmlib.AdbCommandRejectedException: device not found at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.j ava:736) at com.android.ddmlib.AdbHelper.executeRemoteCommand( AdbHelper.java: 373) at com.android.ddmlib.Device.executeShellCommand(Devi ce.java:285) at com.android.ddmuilib.logcat.LogPanel$3.run(LogPane l.java:516)
[2010-09-20 10:40:46 - DeviceMonitor]Sending jdwp tracking request failed!
Also, is there a way to capture the TEXT from CMD window that runs while the Emulator is coming up
View 2 Replies
View Related
Sep 20, 2010
My Helloworld tutorial sample builds and runs just fine, except it doesn't show the text (i.e. loads apps). The only thing I see is that Emulator (Target 2.2 API level 8) comes up with just the "Android" in it. and then the emulator shows up a locked up screen in a while. Here is output from the console
[2010-09-20 10:36:55 - HelloAndroid] Android Launch!
[2010-09-20 10:36:55 - HelloAndroid] adb is running normally.
[2010-09-20 10:36:55 - HelloAndroid] Performing com.example.HelloAndroid.HelloAndroid activity launch
[2010-09-20 10:36:55 - HelloAndroid] Automatic Target Mode: Preferred AVD 'my_avd' is not available. Launching new emulator.
[2010-09-20 10:37:56 - HelloAndroid] WARNING: Application does not specify an API level requirement!
[2010-09-20 10:37:56 - HelloAndroid] Device API version is 8 (Android 2.2)
[2010-09-20 10:37:56 - HelloAndroid] HOME is up on device 'emulator-5554'
[2010-09-20 10:38:23 - HelloAndroid] Uploading HelloAndroid.apk onto device 'emulator-5554'
[2010-09-20 10:38:27 - HelloAndroid] Installing HelloAndroid.apk.
After I exit the emulator, I get the following errors.[2010-09-20 09:02:24 - DeviceMonitor]Sending jdwp tracking request failed![2010-09-20 09:38:46 - ddms]nulljava.lang.NullPointerException
at com.android.ddmlib.JdwpPacket.writeAndConsume(Jdwp Packet.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.ja va:573)
at com.android.ddmlib.HandleHello.sendHELO(HandleHell o.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(H andleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.jav a:670)
at com.android.ddmlib.MonitorThread.processClientActi vity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread .java:263)
[2010-09-20 09:38:47 - ddms]null
java.lang.NullPointerException
at com.android.ddmlib.JdwpPacket.writeAndConsume(Jdwp Packet.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.ja va:573)
at com.android.ddmlib.HandleHello.sendHELO(HandleHell o.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(H andleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.jav a:670)
at com.android.ddmlib.MonitorThread.processClientActi vity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread .java:263)
[2010-09-20 09:50:11 - DeviceMonitor]Sending jdwp tracking request failed!
[2010-09-20 09:59:29 - DeviceMonitor]Sending jdwp tracking request failed!
[2010-09-20 09:59:31 - Logcat]device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.j ava:736)
at com.android.ddmlib.AdbHelper.executeRemoteCommand( AdbHelper.java:373)
at com.android.ddmlib.Device.executeShellCommand(Devi ce.java:285)
at com.android.ddmuilib.logcat.LogPanel$3.run(LogPane l.java:516)
[2010-09-20 10:40:46 - DeviceMonitor]Sending jdwp tracking request failed!
Also, is there a way to capture the TEXT from CMD window that runs while the Emulator is coming up?
View 5 Replies
View Related
Oct 16, 2009
I have an activity that loads and displays images from the SDCard. I create a new AVD, specify the desired image of the sd card (which has all my pictures already loaded), specify that AVD for deployment, and start the application. I noticed a strange behavior. At first, the images are not loaded; the getView method is never called, although the constructor of my adapter is called. If I close the application, and open the Gallery app that comes pre-installed, I see that the sd card folder has the correct number of images, and it 'displays' the first four. If I start my application again, those four images are displayed, and only those. If I go back to the Gallery application, open the sd card folder so that it loads all images, and restart my application, all images are successfully displayed. Any reason why this happens? I am using version 1.6, and (part of) my code is below: Code...
View 2 Replies
View Related
Jul 27, 2010
How do I figure out, if an app is loaded for the first time after it has been downloaded. I mean when the app is first bought/downloaded from market, how will I figure it that this is the first time(never has been run on this phone) this is going to run hence I can throw up some registration activity?
View 6 Replies
View Related
Apr 6, 2010
I have an Android application that works off of a smaller database, around 300 entries. To view the database, I have created a custom view that contains individual rows of data. Then I query the database, and add each line to a newly created custom view.
The problem is that it takes a little white for all of this to be created/loaded, so when you open the application, it sits for a few seconds.
How can I load one line of data, then display it, then the next, append it, etc.?
View 1 Replies
View Related
Jun 2, 2010
I have an extended BaseAdapter in a ListActivity: private static class RequestAdapter extends BaseAdapter{ and some handlers and runnables defined in it
CODE:.......
In the getView function of the Adapter, I'm getting the view like this:
CODE:..........
and the image is getting loaded this way:
CODE:.................
Now, the problem I'm having is that if there are more items that need to display the same picture, not all of those pictures get displayed. When you scroll up and down the list maybe you end up filling all of them.
When I tried the commented out line (holder.avatar.setImageBitmap...) the app sometimes force closes with "only the thread that created the view can request...". But only sometimes.
View 3 Replies
View Related
Sep 23, 2010
Is there something like a an Android file explorer so that the application could be installed from an SD card on versions older than 2.2 if the signed .apk file was manually copied onto the SD card? (Kind of like installing from a web page.)
View 2 Replies
View Related