android - Time Picker widget - "id cannot be resolved or is not a field" -
i'm getting error following lines:
mtimedisplay = (textview) findviewbyid(r.id.timedisplay); mpicktime = (button) findviewbyid(r.id.picktime);
although @ stage i'm merely copy-pasting stuff tutorial, feel it.. going wrong guys?
this .java file whole:
package com.example.hellotimepicker; import java.util.calendar; import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.textview; public class hellotimepicker extends activity { /** called when activity first created. */ private textview mtimedisplay; private button mpicktime; private int mhour; private int mminute; static final int time_dialog_id = 0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); // capture our view elements mtimedisplay = (textview) findviewbyid(r.id.timedisplay); mpicktime = (button) findviewbyid(r.id.picktime); // add click listener button mpicktime.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { showdialog(time_dialog_id); } }); // current time final calendar c = calendar.getinstance(); mhour = c.get(calendar.hour_of_day); mminute = c.get(calendar.minute); // display current date updatedisplay(); } // updates time display in textview private void updatedisplay() { mtimedisplay.settext( new stringbuilder() .append(pad(mhour)).append(":") .append(pad(mminute))); } private static string pad(int c) { if (c >= 10) return string.valueof(c); else return "0" + string.valueof(c); } }
sounds missed copy layout (xml code) tutorial
Comments
Post a Comment