java - HashMap<String, List<String>> may not contain objects of type 'integer' -


i have written code displaying expandablelistview on android studio. code explandablelistview:

public class recipes extends appcompatactivity implementsview.onclicklistener           { expandablelistview exp; edittext t; button b;   hashmap<string, list<string>> movies_category; list<string> movies_list; expandablelistview exp_list; moviesadapter adapter;  protected void oncreate(bundle savedinstancestate) {     settheme(r.style.noactionbar);     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_recipes);     t = (edittext) findviewbyid(r.id.t);     b = (button) findviewbyid(r.id.b);     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_recipes);     exp_list = (expandablelistview) findviewbyid(r.id.exp_list);     movies_category = dataprovider.getinfo();     movies_list = new arraylist<string>(movies_category.keyset());     adapter = new moviesadapter(this, movies_category, movies_list);     exp_list.setadapter(adapter);     t.setonclicklistener(this);     b.setonclicklistener(this); }  @override public void onclick(view v) {     startactivity(new intent(this, choose.class));     } } 

and methods perform operations:

public class recipeada extends baseexpandablelistadapter{ private context ctx; private hashmap<string, list<string>> recipes; private list<string> ingr; public recipeada(context ctx,hashmap<string, list<string>>recipes, list<string> ingr) {      this.ctx=ctx;     this.recipes=recipes;     this.ingr=ingr; }  @override public int getgroupcount() {     return recipes.size(); }  @override public int getchildrencount(int groupposition) {     return recipes.get(ingr.get(groupposition)).size(); }   @override public object getgroup(int groupposition) {     return recipes.get(groupposition); }  @override public object getchild(int parent, int child) {     return recipes.get(ingr.get(parent)).get(child); }   @override public long getgroupid(int groupposition) {     return groupposition; }   @override public long getchildid(int parent, int child) {     return child; }  @override public boolean hasstableids() {     return false; }  @override public view getgroupview(int parent, boolean isexpanded, view convertview, viewgroup parentview) {     string grptit= (string) getgroup(parent);     if (convertview==null)     {         layoutinflater inf= (layoutinflater) ctx.getsystemservice(context.layout_inflater_service);         convertview=inf.inflate(r.layout.parent_layout,parentview,false);     }     textview pa= (textview) convertview.findviewbyid(r.id.textview4);     pa.settypeface(null, typeface.bold);     pa.settext(grptit);     return convertview; }   @override public view getchildview(int parent, int child, boolean lastchild, view convertview, viewgroup parentview) {     string childtitle= (string) getchild(parent,child);     if (convertview==null)     {         layoutinflater inf= (layoutinflater) ctx.getsystemservice(context.layout_inflater_service);         convertview=inf.inflate(r.layout.child_layout,parentview,false);     }     textview ch= (textview) convertview.findviewbyid(exp_list);     ch.settext(childtitle);     return convertview; }  @override public boolean ischildselectable(int groupposition, int childposition) {     return false; }} 

it shows warning @ "groupposition" in function definition of:

@override public object getgroup(int groupposition) {     return recipes.get(groupposition); } 

when hovered on it, says hashmap<string, list<string>> may not contain objects of type 'integer'
how correct this?
also, how accept contents(string) user , save in database?

to create hashmap takes 2 things: key , type. type(in case list) need pass key(in case string). meaning if want to .get current code have pass string. if want use integers instead, change hashmap to:

private hashmap<integer, list<string>> recipes; 

alternatively, integer.tostring(id); if want use strings numbers

also, how accept contents user

depends on mean "accept content". if mean passing string hashmap can .put(id, "some string");

and save?

external data,
internal data,
sql,
sharedprefs


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -