debugging - Eclipse Android - Debugger doesn't stop at breakpoint on OnClick method -
i want debug onclick
method in saveactivity
:
public class saveactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_save); getactionbar().setdisplayhomeasupenabled(true); } // button // (http://developer.android.com/training/implementing-navigation/ancestral.html) @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case android.r.id.home: // called when home (up) button pressed // in action bar. intent parentactivityintent = new intent(this, mainactivity.class); parentactivityintent.addflags(intent.flag_activity_clear_top | intent.flag_activity_new_task); startactivity(parentactivityintent); finish(); return true; } return super.onoptionsitemselected(item); } public void onclick(view view) { switch (view.getid()) { // <-- on line breakpoint case r.id.location_save: edittext formname = (edittext) findviewbyid(r.id.location_name); string locationname = formname.gettext().tostring(); edittext formdesc = (edittext) findviewbyid(r.id.location_desc); string locationdesc = formdesc.gettext().tostring(); // example new york string locationlatitude = "40.714353"; string locationlongitude = "-74.005973"; databasehandler db = new databasehandler(this); location newlocation = new location(locationname, locationdesc, locationlatitude, locationlongitude); db.addlocation(newlocation); intent myintent = new intent(saveactivity.this, detailactivity.class); myintent.putextra("id", newlocation.getid()); saveactivity.this.startactivity(myintent); } }
}
now added breakpoint on switch
-statemant in onclick method. click on button in activity_save.xml
:
<button android:id="@+id/location_save" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/location_save" > </button>
so should stop @ breakpoint, nothing happend.
did wrong?
add in button layout bind method onclick:
android:onclick="onclick"
Comments
Post a Comment