1-when run it,emulator not allow show button. 2-this code: package fatemi.prj.newsample4;
import android.os.bundle; import android.app.activity; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import java.util.date; public class mainactivity extends activity { /*main activity*/ button btn=new button(this); private onclicklistener btnonclicklistener= new onclicklistener() { public void onclick(view v) { /* click button showing date*/ updatetime(); } }; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); btn.setonclicklistener(btnonclicklistener); updatetime(); setcontentview(btn); } private void updatetime() { /* defne update function*/ btn.settext(new date().tostring()); } }
Comments
Post a Comment