Guest User

Untitled

a guest
Jan 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1.  
  2.     /**
  3.      * Get an array with file names of all category images in drawable folder.
  4.      *
  5.      * @return the file names of all catergories in drawable folder.
  6.      */
  7.     public String[] getCategoryDrawables() {
  8.         Field[] fields = R.drawable.class.getFields();
  9.         String[] categoryDrawables = new String[fields.length];
  10.  
  11.         // Place all category images in the array.
  12.         for (int i = 0; i < categoryDrawables.length; i++) {
  13.  
  14.             // Iterate through NoteCategories and get the drawables that matches
  15.             // the category names.
  16.             for (NoteCategory category : NoteCategory.values()) {
  17.                 if (category.toString().equals(categoryDrawables[i])) {
  18.                     categoryDrawables[i] = fields[i].getName();
  19.                 }
  20.             }
  21.         }
  22.  
  23.         return categoryDrawables;
  24.     }
Add Comment
Please, Sign In to add comment