java - Show TextView from Main method in widget -


hey guys want program application shows countdown specific day. on top of want offer widget. main activity ok don't know how reference of textview in main activity. show code(sorry i'm beginner :) )

main:

public class mainactivity extends activity {      private static final string tag = mainactivity.class.getsimplename();      textview tv;     long diff;     long milliseconds;     long endtime;      @override     public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);      typeface tf = typeface.createfromasset(getassets(), "fonts/pricedow.ttf");     tv = (textview)findviewbyid(r.id.textview1);     tv.settypeface(tf);      simpledateformat formatter = new simpledateformat("dd.mm.yyyy, hh:mm");     formatter.setlenient(false); 

......................................................................................

widget:

public class exampleappwidgetprovider extends appwidgetprovider {      public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) {         final int n = appwidgetids.length;          log.i("examplewidget",  "updating widgets " + arrays.aslist(appwidgetids));          // perform loop procedure each app widget belongs provider         (int = 0; < n; i++) {             int appwidgetid = appwidgetids[i];              // create intent launch exampleactivity             intent intent = new intent(context, mainactivity.class);             pendingintent pendingintent = pendingintent.getactivity(context, 0, intent, 0);             textview tu = (textview) findviewbyid(r.id.textview1);              // layout app widget              remoteviews views = new remoteviews(context.getpackagename(), r.layout.widget1);              // tell appwidgetmanager perform update on current app widget             appwidgetmanager.updateappwidget(appwidgetid, views);         }     } } 

is possible show tv main activity in widget? :)

many greetings germany ;)

you reference textview this..

textview tv = (textview) findviewbyid(r.id.mytextview); 

mytextview id of textview on layout, textview1 default.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -