android - How can i set text to text view in the base adapter? -


i'm beginner in android ,write simple adapter:

public class customadapter extends baseadapter{      public customadapter(mainactivity mainactivity, string[] prgmnamelist, string[] prgmimages) {            //do something... , dont write code     }     @override         public view getview(final int position, view convertview, viewgroup parent) {         //want write code>>>>textview1.settext("hello");      }  } 


, call adapter in main activity line:

 lv=(listview) findviewbyid(r.id.mylist);                 lv.setadapter(new customadapter(mainactivity.this, prgmnamelist,prgmimages)); 


want when custom adepter call , process thing,write result main activity text view.how can this?thanks.

try this, 1 method, can find different methods also.

create function in activity class

public void refreshdata(){     //code set text } 

and call function adapter using context.

eg: in adapter class, call this.

((mainactivity)context).refreshdata(); 

you can use interface, but, in case, no need use that, using context fine purpose.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -