I would like to create a user interface which would contain network indication icons (3G, WiFi...) and I would like to use existing graphic elements which are displayed in notification bar.
Does anyone know how to get these existing elements and use it in custom layout?
I guess these icons are all ImageView elements and I am wondering whether it is possible to retrieve them with findViewById() method.
They are drawables in android.R.drawable. There is a list of avaiable drawables for 1.0 at drawable list
You can go to http://source.android.com/download to get instructions on how to download Android sources (images/drawables included), search for *.pngs and then reference the ones you need like this: getResources().getDrawable(android.R.drawable.ic_menu_save).
P.S. At least some of the drawables come with sdk: $SDK_PATH\platforms\android-1.5\data\res\drawable
Related
I'm trying to render a loading circle in one activity whose data gets populated by an async task. I'm not using default progressbar, because the icon in older version of Android looks like this:
I know how to use an ImageView or ProgressBar with a custom image and a rotation animation, but I haven't been able to find new official Android's looking icon anywhere. The one that looks like this:
Or maybe there is another way to generate this kind of spinning wheel animation in Android 2.2.
In general it's good to stick with the style set on that system.
If you still want the newer spinning wheel animation, set the indeterminateDrawable XML property on the ProgressBar. You can find the drawable XML files in the SDK folder under [android-sdk]\platforms\android-17\data\res\drawable called progress_medium.xml and others. You'll also need the referenced icon files stored in the drawable-**** folders.
check folder SDK_DIR\platforms\android-x\data\res\drawable-hdpi.
There should be spinner drawables like "spinner... "
I am trying to emulate the UI used by the gmail tablet app. When an item in the list view to the left is in an "activated" state I wish to draw an arrow indicator linking the list row to the main content fragment on the right-hand side. The "arrow" I am referring to is circled in this image:
Gmail App Screenshot
I have achieved this by using background drawables for the list rows which is satisfactory; however, I want to make use of a divider to separate the list and the main content area. So my question is how could I achieve this without using a background drawable? I tried having the arrow indicator as a child of the list row and attempting to draw it 1 pixel outside the row to cover the divider but this did not work.
Any help is appreciated, thanks.
Your question is similar to these:
Shadow Separator Between Android Fragments
ListView row marker ala GMail
Reading their answers it seems the easiest way to do what you want is using background 9-patch drawables.
In fact, the Gmail app uses 9-patch PNGs to achieve this effect. You can see it for yourslef if you take a look to the PNG files inside Gmail APK's res/drawable-hdpi folder (you will need a tool like AirDroid to obtain the APK from your device).
Is there any way to programmatically select an alternative resource file to use in the app? I have a selection of buttons in my app, and want to use a different set whenever my app is in a certain mode.
Is there any way to achieve this other than manually setting the image resource on every image in code?
You can create a layout filled with exactly the views you want and inflate that at any time. Though maybe I'm not understanding your question... do you wish for R.drawable.myImage to point to 2 different things? The answer to that is no, that's not possible, but it seems like it would be pretty easy to get around this need by creating two (or more) "pointer" arrays that can point to whatever resources you want, and set those as the src for your images.
Declare a two-dimensional array to store the resource constant.
int[][] sets { {R.id.a, R.id.b, R.id.c}, {R.id.d, R.id.e, R.id.f}};
You can choose the set of views by changing the first index of the array set.
I am looking to build a button in my Android app which must contain:
A background picture
A picture
Some text
I am coming from iPhone dev and I am a little bit confused by Android development.
While I could addSubView: UIImageView or UILabel to my UIButton, I can't use addView() with a android.widget.Button :(
Does anyone have a solution?
EDIT : Thanks everybody for answers. I forgot to specify I have to do it programmatically, without using XML. I don't know how many element I will display (it depends on RSS).
android:background for background ... remeber that you can build your own 9 patch
android:drawableLeft, android:drawableRight, android:drawableTop, android:drawableBottom to add some picture to the left, right, ... of text
EDIT: i didn't mention ... but i was talking about android.widget.Button
2nd EDIT: after you provide more information i think that all what you need is ListView
check this sample http://esilo.pl/LooserSample.zip (don't take "looser" to yourself, it was sample for another guy)
it showing how to
download a JSON data
store it in db
build ContentProvider for sharing a data
use ContentProvider to take data from db and show it in ListView
dynamic loading images from internet
for simpler sample use your sdk samples like this C:\android\android-sdk-windows\samples\android-8\ApiDemos\src\com\example\android\apis\view\List*.java
if you alrady have code for downloading and storing data from RSS in array extend ArrayAdapter to fit your needs
Most, if not all, of the UI for android is built in the XML. Kind of like the UI builder in Xcode, but not near as advanced. The ADP will let you view the UI you have built in Eclipse, and adjust some basic widget properties.
I believe for what you are trying to do, if I understand right, you need to use an ImageButton widget. This widget allows you to use a complete image as a button. You can also define your own states (button pressed, gain focus, etc) with both the button and image button widgets. You can define a background and add images to both widgets.
More information here
I want to develop an android application, but i dont want to use the default controls(buttons, checkboxes, radio buttons, etc.,). Is there any way to customize those controls to make it appear nicer. If so some tutorial or guide will help me a lot. Thanks....
If you want to create completely new UI elements, you should read the developer guide topic on creating custom components/views.
If, on the other hand, you simply want to change the appearance of existing UI elements, below is a non-exhaustive list of things you'll need to do. This assumes you're familiar with the Android resources framework and layout system.
First, see how these are implemented in the Android source code (AOSP, GitHub's mirror). All of the code you're interested in is in the frameworks/base.git project (quick links: resources, Java sources)
For each type of UI element, create Nine Patch PNG drawables for each of the UI states (default, disabled, pressed, focused, etc.) and for each relevant density (e.g. medium, high , and extra-high densities). These PNGs should be in your res/drawable-mdpi/, res/drawable-hdpi/, and res/drawable-xhdpi/ directories.
For each type of UI element, create a state list XML drawable (<selector>), which will be in your res/drawable/ directory. The state list drawable for the default Android push button can be found here.
Set your button/textbox/etc.'s android:background attribute to the state list drawable name. For example, the attribute value should be #drawable/mybutton if your state list drawable is res/drawable/mybutton.xml. Note: You can use themes to reduce redundancy (i.e. keep them DRY) in your XML files.