私のonClick
メソッドをデバッグしたいSaveActivity
:
public class SaveActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_save);
getActionBar().setDisplayHomeAsUpEnabled(true);
}
// For the Back Button
// (http://developer.android.com/training/implementing-navigation/ancestral.html)
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// This is called when the Home (Up) button is pressed
// in the 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 this line is my 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 for 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);
}
}
}
switch
onClick メソッドの -Statemant にブレークポイントを追加しました。次に、このボタンをクリックします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>
したがって、ブレークポイントで停止するはずですが、何も起こりませんでした。
私は何を間違えましたか?