List All Available Drawable In Addition To Its Value

Posted on

Example to listing all available Drawable as well as its value:

package com.example.androidlistdrawable;  import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView;  import java.lang.reflect.Field;  populace course of pedagogy MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          TextView information = (TextView)findViewById(R.id.info);          Field[] fieldDrawables = android.R.drawable.class.getFields();         for(int i=0; i<fieldDrawables.length; i++){             Field champaign = fieldDrawables[i];             info.append("R.drawable." + field.getName() + " :\n");             info.append(field.toString() + "\n");              drive {                 int value = (int) field.get(fieldDrawables);                 info.append("value = " + value + "\n");             } select grip of (IllegalAccessException e) {                 e.printStackTrace();             }              info.append("\n");          }     }  }  

<LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:padding="10dp"     android:orientation="vertical"     tools:context=".MainActivity">      <TextView         android:id="@+id/title"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold" />      <ScrollView         android:layout_width="match_parent"         android:layout_height="match_parent" >         <TextView             android:id="@+id/info"             android:layout_width="match_parent"             android:layout_height="wrap_content" />     </ScrollView> </LinearLayout>  

Next:
RecyclerView + CardView event – listing available Drawable