Android :: Dynamically Get Drawables By ID
Mar 10, 2010
I want to take a byte and append it to a resource ID to be able to get the image that corresponds to that numbered deck in the game. It was easy to with paths on other devices, but with the Resource ID's I am unsure how I could go about do this.
Here's what I have now:
CODE:..................
In my Blackberry version of this, I simply had:
CODE:.....................
Is there a way to accomplish something similar using Resource IDs on Android?
View 1 Replies
Aug 23, 2010
Is there a way to extend a drawable (just like how shapes work, create your own tag) and allow it to be inflated from XML? Or is drawable only for the allowed 9 types?
View 1 Replies
View Related
Sep 23, 2012
Im developing an app which is a product catalogue. Users can search for and view products (books). It's all read only and just so allow user's to view products. When the user clicks on a product, the next screen displays
- book title
- book author
- picture of front cover.
It's the picture part that I've a question about. I know one way to present drawables is to have them in the "drawable" direction in my android project and access them (in my xml file) as android:src="@drawable/name".
Only problem is that new products will be added so I can't store drawables in the APK file when I release it. I'll need to read them at runtime. I'm wondering what the best way to approach this is.
I'm thinking of upon app launch executing an AsyncTask which would call
openConnection of HttpURLConnection and would grab down all drawable(from a particular remote directory on a website) and would then store them in the sqllite db (as a blob). Each product in the db could easily be associated with it's specific drawable.
Not sure if there's a better approach to this ? or should I save them to the internal storage of the device (I know the size is an issue with this option). Or I could, when I show the product, call the Async task to present the image - i.e.get the image when the user requests it. This sounds good.
View 1 Replies
View Related
May 19, 2009
I am using a SurfaceView, and wish to animate Drawables. All the animation tutorials I have seen concern using an ImageView, which as I understand is not a sensible approach from within a SurfaceView. Does anyone have any suggestions for doing frame-by-frame animation within a SurfaceView? Can it be done with openGL?
View 4 Replies
View Related
Jul 25, 2009
I'm trying to draw a "gauge" on the screen with information from various sensors. I have a class that extends Drawable and a custom view that during construction creates a new AnimationDrawable and sets the only frame to my custom Drawable. I then start the AnimationDrawable from my Activity onWindowFocusChanged method. My custom Drawable onDraw method is only called once though. Is that by design (as in onDraw is called for each frame once and it's cached and shown over and over) or am I doing something wrong?
CODE:..................
View 2 Replies
View Related
Sep 12, 2010
My application has alot of pictures in it and I was wondering if its possible if one of my users click a button to send that picture to the sd card?
View 2 Replies
View Related
Aug 15, 2010
I want to use a number of ShapeDrawables in my application, which are all similar, but with different colours etc. Obviously I could just define them all in separate xml files, but is there a more efficient way to have one xml definition, instantiate various objects and change the colour either in code or xml? You could perhaps do this by calling mutate() on one ShapeDrawable defined in xml, but this returns a Drawable, rather than a shape drawable.
View 1 Replies
View Related
Jan 24, 2010
Is there any way to use an image that I'm generating on the fly as a Notification icon?
View 2 Replies
View Related
Jun 1, 2010
How do access a drawable which resides in my project's res/drawable folder from outside an activity? The component which handles the loading of images is generic and is not inside any activity. I would like to display an image from res/drawable in case it can't be fetched from the web.
View 2 Replies
View Related
Nov 7, 2010
I'm trying to create an appwidget with a customizable background. I use a NinePatchDrawable and I would like to change it's color (using the setColorFilter method). This is no problem in an Activity, but it does dot seem possible with the RemoteView object used for appwidgets.Is there some way to get an ImageView in an appwidget to be updated with a new Drawable, not a Bitmap?Or if not, perhaps it's possible to get the actual size of the appwidget and convert / save the colored NinePatchDrawable to a Bitmap and then update the ImageView with that?I already searched quite a bit for a solution, but haven't found anything so far. I hope it's not impossible.
View 2 Replies
View Related
Sep 17, 2010
I am using some drawable objects, when I instance them and paint in my canvas they doesn't get the original PNG image file size, instead they get a bigger size, so they does't paint in my canvas as I expected since I wanted them in their original sizes, why this happens?
(original file is 96x96 pixels)
mSprite = mRes.getDrawable(R.drawable.my_sprite);
mSpriteWidth = mSprite.getIntrinsicWidth();
// It returns 114, not 96 mSpriteHeight = mSprite.getIntrinsicHeight();
// It returns 114, not 96
mSprite.setBounds(coordX, coordY, coordX + mSpriteWidth, coordY + mSpriteHeight); mSprite_PipeRect.draw(canvas); //It paints at 114x114 size, it shows bigger in the screen then original size.
Something similar happens with the background but it is fixed in the "setSurfaceSize" event this way:
public void setSurfaceSize(int width, int height) {
mBackgroundImage = Bitmap.createScaledBitmap(mBackgroundImage, width, height, true);
}
View 3 Replies
View Related
May 4, 2010
I am working with a library of maps which paints the icons on the map using drawables and canvas. Now, i'm trying to modify it in order to the user can click on icons. So i want to attach drawables into different ImageView with a onClickListener. However, i don't know how i can paint the ImageView using canvas from method onDraw.
I've tried with:
ImageView iv = new ImageView(context);
iv.setDrawableResource(drawable);
iv.draw(c)
But it doesn't appears in screen.
View 1 Replies
View Related
Sep 4, 2009
I need a textview with multiple drawables at bottom. In android, I know that there is a possibility of giving one image drawable for bottom. But i need multiple to be drawable at bottom.
View 2 Replies
View Related
Jan 5, 2010
When creating a stateful drawable, I cannot find the other drawables (9-patch images) that are there - i get no "suggestions" ("intelliSense").
But if I try to find drawables in another XML-file there is no problem.
This is my stateful drawable
CODE:..............
The "view_background_pressed" etc are all there, and they can be found in other XML-files but not in the statefule drawable.
View 2 Replies
View Related
Mar 7, 2010
When I add drawable resources to my project they do not show up in the list of drawables in the Reference Chooser. I checked the R file and there are references for the files.
I have tried refreshing the project, cleaning the project, and fixing project properties and nothing seems to help. Sometimes a couple will randomly show up in there, but not all of them.
The only consistent way I can get them to show up is to restart Eclipse.
Further findings:
After some trials, I found an other inconvenient work around to he issue. Turns out when importing multiple files into the project at once, Eclipse will only add the last one imported into the reference chooser. So when I imported my images one at a time, they all show up properly!
Like I said, inconvenient considering the amount of images I have left to import, but maybe with this new information it may help nail down where the issue may be and a possible fix.
View 2 Replies
View Related
Mar 29, 2010
I would like to display all resource drawables in a list so that the user can select one. Is there any way to loop through all R.drawable items so I don't have to hard code them into my program?
View 2 Replies
View Related
Jul 8, 2010
What is the best approach when using default Android drawables? Should I use android.R.drawable or should I copy the drawables in my project and use R.drawable?
Is there any risk, that in a newer version of Android, some of the default drawables are removed or resized? Or, affect in some negative way, the look of my app? Also, which of the drawables in the Android source code are considered "stable" and should be relied on?
I'd rather not copy the drawables because I think that the look of the app should be consistent with the Android version used. So, for example, for version 1.6 it should use the default Android bitmaps for version 1.6.
View 4 Replies
View Related
May 9, 2010
I am trying to modify this example:
http://developer.android.com/resources/tutorials/views/hello-gridview.html
But instead of displaying images that are resources, I want to display Drawables that I currently am storing in a List.
Can anyone instruct me on how I would modify
code...
To display my drawable items instead?
View 1 Replies
View Related
Nov 11, 2010
I'm writing an app that shows in google maps pipes and valves(lines and points). For that i've two classes.
One extends from ItemizedOverlay, and i add to map overlay one for each category of valve, and each one can have more than one item.
The second extends from Overlay, and in the draw method y draw the line with the method drawline of the canvas.
The problem i've is that the lines are drawn over the ItemizedOverlay items, no matter the order i add them to the mapView.getOverlays().
I want the lines on the bottom of all overlays. is there a way to do that.
View 1 Replies
View Related
Sep 9, 2010
Is it possible to add drawables to the positive, negative and neutral buttons of an AlertDialog? If yes, then how?
View 1 Replies
View Related
Sep 4, 2009
I'm defining my options menu in an XML file and I want to add an icon to the menu items. Normally, this would be sth like -- < (...) android:icon="@drawable/iconfile" />.But I want to use the drawables that are already stored in the android.jar (as listed here: http://www.screaming As the website says, I can access them via -- myMenuItem.setIcon(android.R.drawable.ic_menu_save); But how can I do that in XML? I tried several things but none worked for me.
View 3 Replies
View Related
Jul 23, 2010
Looking at the following image, the button on the left is android 2.1, the one on the right is 2.2:
As you can see the corners on the left image are not being applied correctly, but they look perfect in 2.2.
The xml I'm using is here:
CODE:..................
Am i doing something wrong, or is this a bug in android 2.1?
View 1 Replies
View Related
Jul 20, 2010
I would like to define the following layout (which is currently an xml file) dynamically in my code.
The end goal is to have the ability to conditionally include certain pages in my viewflipper. code...
View 1 Replies
View Related
May 1, 2010
In my app i want to set the logo in the title bar. but depending upon the size of the device how could it be set,so it may be dynamically possible.
View 2 Replies
View Related
Jul 13, 2009
I've learned that to set typeface needs font to be under asset folder how to dynamically load the ttf file to be used in code? or maybe how in runtime to add ttf file into the asset folder? is there any solution for this problem?
View 3 Replies
View Related
Nov 2, 2009
I am trying to make ListView which should display data from db. But the db is filled slowly so want the entries in the ListView to grow dynamically according to the elements in db. For example on a desktop music player when you import a folder to the music library the list with songs is filling in real time with the newly added songs. So how can i get this working on android.
View 5 Replies
View Related
Sep 28, 2010
I want to dynamically load a ListView, for example, load them during the scrolling so its not loading all 100 posts I have. How can I achieve this?
I have looked at similiar solutions here at SO, but since I not got it to work, I asked this question.
My code:.............
I have in the same .java file, functions to download the info from the web and loop through 100 items, like this:
CODE:................
And then it add a new order correctly and so on. But now!(?) I want to have so when the first item is loaded, it should appear and when scrolling it loads gradually.
View 1 Replies
View Related
Apr 21, 2010
I want to implement a "Settings" section in my application, and I want that when the user selects whatever, one of the strings from string.xml will change its value according to the user selection. Is this possible at all? any ideas on how to implement it?
View 4 Replies
View Related
Mar 15, 2010
Is it possible to write an Softkeyboard without XML or is this the time I'll need it?The idea is: I have an Arraylist with buttons which have a specific position in the layout, height, width, text etc. Those buttons should create my keyboard by converting them into keys.If this won't work, my second idea is, to write a XML-File out of Java.I wonder if one of these ideas are possible.
View 2 Replies
View Related
May 28, 2010
I am currently learning about widgets in Android. I want to create a WIFI widget that will display the SSID, the RSSI (Signal) level. But I also want to be able to send it data from a service I am running that calculates the Quality of Sound over wifi. Here is what I have after some reading and a quick tutorial: public class WlanWidget extends AppWidget Provider {RemoteViews remoteViews; AppWidgetManager appWidgetManager; Component Name thisWidget; WifiManager wifiManager; public void onUpdate(Context context, AppWidgetManager appWidget Manager, int[] appWidgetIds) { timer timer = new Timer(); timer.schedule AtFixed Rate(new WlanTimer(context, appWidgetManager), 1, 10000); The above seems to work ok, it updates the SSID on the widget every 10 seconds. However what is the most efficent way to get the information from my service that will be already running to update periodically on my widget? Also is there a better approach to updating the the widget rather than using a timer and timertask?
View 12 Replies
View Related