How to get drawable resource in android programmatically? [duplicate] - android

This question already has answers here:
Android getResources().getDrawable() deprecated API 22
(16 answers)
Closed 18 days ago.
I want to get the drawable id which is shown in the screen.
I used
if(getResources().getDrwable(binding.image1)==R.drawable.image){ //my stuff}
But this is depreciated.

You can use alternative of getResources().getDrawable(int id) as mentioned below
ContextCompat.getDrawable(Context context,int drawableId)

Related

What is the Const and Val are immutable.How they are differ in programm [duplicate]

This question already has answers here:
What is the difference between "const" and "val"?
(9 answers)
Closed 12 months ago.
Val in kotlin is a immutable one and Const also immuntable one.How they are differnt in programm....Explain me in a code
You can read the differences between them both in: https://www.geeksforgeeks.org/whats-the-difference-between-const-and-val-in-kotlin/

Android Java getId() name not int value [duplicate]

This question already has answers here:
How to get a resource id with a known resource name?
(10 answers)
Closed 8 years ago.
Lets say i have a few views and I want to get the id name of their IDs
view.getId()
returns an int value but instead i want to get the name of the id
android:id="#+id/valueFrance"
So is there any method on java that can return the name/value of the id ( "valueFrance" ) ?
Thank you very much.
try this
getResources().getResourceEntryName(int resid);

What does f means in animation [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What does suffix ‘f’ mean in Android programming?
Excuse me if it was a stupid question, but I always see people writing something like 350f and 15f when initializing animations (passing as paramter) . What does f mean?
Thank you
I believe it's the format of the argument, FLOAT in this case.

Access the values of res/values/strings [duplicate]

This question already has answers here:
Difference between getString() and getResources.getString()
(3 answers)
Closed 9 years ago.
I read about String Resources and I understood that you simply use the getString(...) method in order to read the value of a string from res/values/string.xml. Then I read that you can also use getResources().getString(...).
What is the difference between these two ways of obtaining the value of a string?
No any difference. They're both equal.

List array in a list view [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
ListView issue when displaying strings
I have the following code
List<Result> results = response.results;
i need the the values in "results" to be displayed in a listview. what should i write within for (Result result : results){}
You've asked a general question so the best I can do is give you a general answer. You don't use for(Results result: results){} You need to use an ArrayAdapter. For a tutorial on how to do so, please see this documentation.

Categories

Resources