java - Android: Using Assets Folder to create an ArrayList of Custom Objects -


i want use asset folder way initialize hierarchical objects(categories). each category has name, image, , list of words(code below).

i made subdirectory in asset folder assets/categories , in subdirectory there several folders named after category represent. inside these folders 1 image(image category) , several other folders named after word represent each word folder containing images. want create categories looping through each subdirectory , getting folder names , images. problem need image resource id create objects rather bitmap. achieving goal possible through method , using asset folder incorrectly? suggestions/advice appreciated.

code:

category.java

private string catname; private arraylist<word> words; private int catimg;  public category(){  }  public category(string catname, int catimg, arraylist<word> words){     this.catname = catname;     this.words = words;     this.catimg = catimg; }  public string getcatname(){     return catname; }  public void setcatname(string name){     this.catname=name; }  public arraylist<word> getwords(){     return words; }  public void setwords(arraylist<word> wordset){     this.words = wordset; }  public int getcatimg(){     return catimg; }  public void setcatimg(int imgid){     this.catimg = imgid; }  public word getword(int i){     return words.get(i); } 

word.java

private string wordname; private int[] imgs; private category category;   public word(){  }  public word(string wordname, int[] imgs){     this.wordname = wordname;     this.imgs = imgs; }   public void setcategory(category category){     this.category = category; }  public category getcategory(){     return this.category; }  public string getwordname(){     return wordname; }  public void setwordname(string wordname){     this.wordname = wordname; }  public void setimgs(int[] imgs){     this.imgs = imgs; }  public int[] getimgs(){     return imgs; } 

edit: think can add bitmap parameter constructor. there better way of doing this?


Comments