java - I am not able to use openFileInput() method in my Expandable list adapter -


i have been trying out way read file subs.txt. know there because works in other classes not one. on buffer reader no file exception , when use openfileinput "cannot find symbol method openfileinput()".

     public class expandableadapter extends baseexpandablelistadapter {      private activity activity;     private arraylist<object> childtems;     private layoutinflater inflater;     private arraylist<string> parentitems, child;      public expandableadapter(arraylist<string> parents, arraylist<object> childern) {         this.parentitems = parents;         this.childtems = childern;     }      public void setinflater(layoutinflater inflater, activity activity) {         this.inflater = inflater;         this.activity = activity;     }         @override     public view getchildview(int groupposition, final int childposition, boolean islastchild, view convertview, viewgroup parent) {          child = (arraylist<string>) childtems.get(groupposition);          textview textview = null;          if (convertview == null) {             convertview = inflater.inflate(r.layout.group, null);         }          textview = (textview) convertview.findviewbyid(r.id.textview1);         textview.settext(child.get(childposition));         //textview.settext(html.fromhtml("<a href=http://www.stackoverflow.com> stack overflow "));         // textview.setmovementmethod(linkmovementmethod.getinstance());         convertview.setonclicklistener(new onclicklistener() {              @override             public void onclick(view view) {                 try {                     string link="";                     arraylist<string>a=child;                     fileinputstream fin = openfileinput("subs.txt");                     string test=child.get(childposition);                     string objenc = "";                     file myfile = new file( "subs.txt");                     bufferedreader br = new bufferedreader(new filereader(myfile));                      stringbuilder sbuilder = new stringbuilder();                     objenc = br.readline();                     while (objenc != null) {                         sbuilder.append(objenc);                         objenc = br.readline();                         if (objenc != null) {                              // sbuilder.append("\n");                          }                     }                     br.close();                     objenc=sbuilder.tostring();                     objenc=sbuilder.tostring();                     gson gson = new gson();                     manysubs obj = gson.fromjson(objenc, manysubs.class);                     for(int i=0;i<obj.newposts.size();i++){                         for(int j=0;j<obj.newposts.get(i).list.size();j++){                             if(obj.newposts.get(j).list.get(j).equals(test)){                                 link=obj.newposts.get(j).list.get(j).url;                             }                          }                     }                     intent browserintent = new intent(intent.action_view, uri.parse(link));                     activity.startactivity(browserintent);                 }catch (exception e){                     string q="";                 }             }         });          return convertview;     }      @override     public view getgroupview(int groupposition, boolean isexpanded, view convertview, viewgroup parent) {          if (convertview == null) {             convertview = inflater.inflate(r.layout.child, null);         }          ((checkedtextview) convertview).settext(parentitems.get(groupposition));         ((checkedtextview) convertview).setchecked(isexpanded);           return convertview;     }       @override     public object getchild(int groupposition, int childposition) {         return null;     }      @override     public long getchildid(int groupposition, int childposition) {         return 0;     }      @override     public int getchildrencount(int groupposition) {         return ((arraylist<string>) childtems.get(groupposition)).size();     }      @override     public object getgroup(int groupposition) {         return null;     }      @override     public int getgroupcount() {         return parentitems.size();     }      @override     public void ongroupcollapsed(int groupposition) {         super.ongroupcollapsed(groupposition);     }      @override     public void ongroupexpanded(int groupposition) {         super.ongroupexpanded(groupposition);     }      @override     public long getgroupid(int groupposition) {         return 0;     }      @override     public boolean hasstableids() {         return false;     }      @override     public boolean ischildselectable(int groupposition, int childposition) {         return true;     }   } 

send context adapter , use :

  class mainactivity extends activity {          expandableadapter adapter = new expandableadapter(activity,parent,children);   }  class expandableadapter ... {    public expandableadapter(context context...)    {     mcontext = context;     }    }  context mcontext; mcontext.openfileoutput 

you can use activity send adapter class


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -