Java Programing For Android App Wont Load -
ive been making android app using android develepor kit , created layout medium text , 1 button
it meant show text in dialog when click buttom when run app on device test it freezes , doesnt show button or text added whole device freezes.
i cant figure out ive dont wrong im complete noob @ im hoping can me figure out.
public class mainactivity extends activity implements onclicklistener { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button button1 = (button)findviewbyid(android.r.id.button1); button1.setonclicklistener(this); } @override public void onclick(view v) { dialog d = new dialog(this); d.settitle("success!"); textview tv = new textview(this); tv.settext("some text here."); d.setcontentview(tv); d.show(); } }
if there in logcat, helpful. believe problem here
button button1 = (button)findviewbyid(android.r.id.button1);
assuming have button
in activity_main.xml
androidid="@+id/button1"
, line should be
button button1 = (button)findviewbyid(r.id.button1);
when use namespace android.r.somereference
telling pre-defined android resource
. here resource
1 have declared leave off android.
Comments
Post a Comment