android - Can't figure out correct argument form - calling a method from within a static nested class in Java -


i'm testing code copied java android examples site. i'm trying modify start new activity when user clicks row of current activity. i'm using intent method i'm not able figure out how reference current view instance argument intent method.

i've tried dozens of combinations, , spent 2 days researching. must seem basic many of know, apologies, week #2 me learning java, eclipse , android sdk (target= api 8)

    public class customlistviewdemo extends listactivity { private efficientadapter adap; private static string[] data = new string[] { "0", "1" }; private static string[] titlestring = new string[] { "title1", "title2" }; private static string[] detailstring = new string[] { "detail1", "detail2" };  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     requestwindowfeature(window.feature_no_title);     setcontentview(r.layout.main);     adap = new efficientadapter(this);     setlistadapter(adap); }  @override protected void onlistitemclick(listview l, view v, int position, long id) {     // todo auto-generated method stub     super.onlistitemclick(l, v, position, id);     toast.maketext(this, "click-" + string.valueof(position),             toast.length_short).show(); }  public static class efficientadapter extends baseadapter implements         filterable {     private layoutinflater minflater;     private bitmap micon1;     private context context;      public efficientadapter(context context) {         // cache layoutinflate avoid asking new 1 each time.         minflater = layoutinflater.from(context);         this.context = context;     }      /**      * make view hold each row.      *       */     public view getview(final int position, view convertview,             viewgroup parent) {         viewholder holder;          if (convertview == null) {             convertview = minflater.inflate(r.layout.adaptor_content, null);              holder = new viewholder();             holder.textline = (textview) convertview                     .findviewbyid(r.id.textline);             holder.buttonline = (button) convertview                     .findviewbyid(r.id.buttonline);             holder.dbuttonline = (button) convertview                     .findviewbyid(r.id.dbuttonline);             holder.textline2 = (textview) convertview                     .findviewbyid(r.id.textline2);              convertview.setonclicklistener(new onclicklistener() {                 private int pos = position;                  @override                 public void onclick(view v) {                     // toast.maketext(context, "click-" +                     // string.valueof(pos),                     // toast.length_short).show();          // ******************** error line below *********                     // "no enclosing instance of type customlistviewdemo accessible in scope"                     intent = new intent(customlistviewdemo.this, intenta.class);                     startactivity(i);                  }             });               holder.buttonline.setonclicklistener(new onclicklistener() {                 private int pos = position;                  @override                 public void onclick(view v) {                     toast.maketext(context,                             "delete-" + string.valueof(pos),                             toast.length_short).show();                  }             });              holder.dbuttonline.setonclicklistener(new onclicklistener() {                 private int pos = position;                  @override                 public void onclick(view v) {                     toast.maketext(context,                             "details-" + string.valueof(pos),                             toast.length_short).show();                  }             });              convertview.settag(holder);         } else {             // viewholder fast access textview             // , imageview.             holder = (viewholder) convertview.gettag();         }          holder.textline.settext(titlestring[position]                 + string.valueof(position));         holder.textline2.settext(detailstring[position]                 + string.valueof(position));          return convertview;     }      static class viewholder {         textview textline;         textview textline2;         button buttonline;         button dbuttonline;      }      @override     public filter getfilter() {         // todo auto-generated method stub         return null;     }      @override     public long getitemid(int position) {         // todo auto-generated method stub         return 0;     }      @override     public int getcount() {         // todo auto-generated method stub         return data.length;     }      @override     public object getitem(int position) {         // todo auto-generated method stub         return data[position];     }  } 

}

i have seen many examples how refer outer members of nested classes not found example on find view instance of outer class use method argument. can point me in right direction?

if @ docs, constructor you're invoking (new intent(customlistviewdemo.this, intenta.class)), one:

public intent (context packagecontext, class<?> cls) 

since you're storing context, can fix problem using new intent(this.context, intenta.class) instead.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -