I am specifically looking for the drawable android.R.id.empty.
Does any one have an idea what the source path of that default Android drawable is?
The file where it is defined is located in
YOUR_SKD_DIRECTORY/platforms/A_PLATFORM/data/res/values/ids.xml
It is not a drawable but an id as you can clearly see from android.R.id.empty.
This id is meant to be set on a View which should be displayed in case your ListView is empty.
I stumpled upon a really nice guide for Froyo drawables. And don't forget to use android.R.drawables for your integer id. http://androiddrawableexplorer.appspot.com/
Related
I have used the dependencies to be used as suggested. below is the pic.
build_gradle(module)
now I have selected a black plus icon from vector assets and named it as fab_plus, now I have this file in my drawable folder.
fab_plus_XML
now I tried to used that fab_plus_XML like this. Pic below.
activity_main
Now my question is why is the fab_plus is showing in red.
thanks in advance. pls, help me, someone.
There are two things wrong with the way you are specifying the drawable. To refer to a drawable within your project, you simply use #drawable/your_drawable and to allow backward compatibility of VectorDrawables you should use app:srcCompat as per the guidance.
So in your ImageView, instead of
android:src="#android:drawable/fab_plus"
you should have
app:srcCompat="#drawable/fab_plus"
You will also need to make sure the app namespace is included at the top of your layout xmlns:app="http://schemas.android.com/apk/res-auto" along with the current android and tools namespaces.
you need to use:
app:srcCompat
instead of
android:src
but the tooltip there should exactly tell you this and AFAIR even offer a quick-fix
I'm trying to making a Table with Xamarin.Forms for Android.
First, there is no border on Table. So!
I made a border.xml file and make shape
but when I do build this, an error occurred
'Invalid start tag shape'
I want to know how to fix it.
And ! , Sorry for more question,
after make resource .xml file I want to put in SetBackgroundResource(int resid)
using resid in Resource.Designer.cs.
How I make resid(resource id) for border.xml 's shape and use it?
Thank you Soooooooooooooo much!
When I had a similar problem, I had created a Converter. You can find more example on Xamarin site https://developer.xamarin.com/guides/xamarin-forms/advanced/localization/
I have been reading some post about changing an image in an ImageView.
But everyone asks for setting an ImageView with a custom image, and I want to set a system image inside it.
I made this:
ledicon.setImageDrawable(getResources().getDrawable(R.drawable.presence_busy));
But Eclipse tells me that presence_busy is not recognized.
Why?
I am using presence_online in the XML file,
android:src="#android:drawable/presence_online"
and all works perfectly.
Try this:
ledicon.setImageDrawable(getResources().getDrawable(android.R.drawable.presence_busy));
(When accessing system resouces you have to look them um in android.R not your own.)
I want to set the background of my Gallery by an image (say background.jpg ) in Drawable folder.
As the prototype of the setBackground() method is
void setBackground(Drawable background)
Set the background to a given Drawable, or remove the background.
But I don't know how to refer to my image in this method.
I have tried to refer like this
Gallery galleryModified;
galleryModified.setBackground(background);
But getting error in second line, saying unable to find resource.
Please reply if you know.
Thanks.
It seems, you are setting background from a resource from drawable folder, which have id, R.drawable.background, if it is the case, try following:
galleryModified.setBackgroundResource(R.drawable.background);
All resources in your project is parsed under R class automatically. You should always retrive them as an object, such as: R.drawable.drawable_name This is a basic way to retrieve many resource types. Just replace drawable keyword such as:
R.string.name_of_string_resource
R.id.id_control
Hello I have a drawable myshape.xml, it contains a <shape> and I cannot set an android:id to shapes.
In my code I want to set the background of a view to this file using
catAll.setBackgroundDrawable(getResources().getDrawable(R.id......???));
where myshape.xml does not show up in my R file because it has no id. and I cannot set id to object.
In my XML I do set the shape by simply typing the drawable resource name. But I need to do this programmatically.
You don't need to get the drawable yourself. Use this instead:
catAll.setBackgroundResource(R.drawable.myshape);
For future reference, if you do wish to get the drawable keep in mind that drawables live in the R.drawable namespace. So your code would became:
getResources().getDrawable(R.drawable.myshape);
This is akin to what you do in your XML:
#drawable/myshape
instead of
#id/myshape
The question is really old but googles first hit references to this thread.
So getDrawable(id) is deprecated.
Short solution (kotlin)
yourView.background = ContextCompat.getDrawable(context, R.drawable.your_ressource_id)
For more, please read this: https://stackoverflow.com/a/29146895/4420355