android - passing genric class as fragment -


i creating utility class pass class name extends fragment. fragment method not available in method declaration. code snippet return fragment tag.

private string createfragmenttag(class<? extends  fragment> aclass, boolean addargs) {         stringbuilder stringbuilder = new stringbuilder();         stringbuilder.append(aclass.getclass().getsimplename());         if(addargs) {             stringbuilder.append("-");             **//here argument not calling**             if (aclass.getarguments() != null)                 stringbuilder.append(aclass.getarguments().tostring());         }         return stringbuilder.tostring();     } 

private string createfragmenttag(fragment fragment, boolean addargs) {     stringbuilder stringbuilder = new stringbuilder();     stringbuilder.append(fragment.getclass().getsimplename());     if(addargs) {         stringbuilder.append("-");         **//here argument not calling**         if (fragment.getarguments() != null)             stringbuilder.append(fragment.getarguments().tostring());     }     return stringbuilder.tostring(); } 

would work. mentioned in comments, aclass doesn't have getarguments() method because haven't instantiated class represents yet. if instead pass actual instantiated fragment class parameter, can accomplish actual goal of generating unique string tag fragment.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -