Update: Fixed, this was due to missing properties in views and my not knowing how to work the debugger :)
I'm really new to Android. I've just finished the Notepad tutorial and am making something similar (most of the code is exactly the same). The sequence of events I'm going through:
- Debug app
- Click Menu, which has the correct items
- Click Insert, which opens a new Activity (GoalEdit)
- I hit a breakpoint on the first line of
GoalEdit.onCreate
and get these warnings:
a. (ActivityManager) Launch timeout has expired, giving up wake lock!
b. (ActivityManager) Activity idle timeout for HistoryRecord{...} - I have a breakpoint at
setContentView
inGoalEdit.onCreate
- after this is passed:
a. ActivityThread.perfo: Source not found.
The relevant code is below:
GoalsList.java
/**
* Add a menu to this activity
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, INSERT_ID, 0, R.string.menu_insert);
return true;
}
/**
* Catch the menuItemSelected event
*/
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case INSERT_ID:
createGoal();
return true;
}
return super.onMenuItemSelected(featureId, item);
}
/**
* Open the Edit activity to create a new goal
*/
private void createGoal() {
Intent i = new Intent(this, GoalEdit.class);
startActivityForResult(i, ACTIVITY_CREATE);
}
GoalEdit.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDbGoals = new GoalDbTable(this);
mDbGoals.open();
setContentView(R.layout.goal_edit);
mName = (EditText) findViewById(R.id.name);
Button finishBtn = (Button) findViewById(R.id.finish);
mRowId = (savedInstanceState == null) ? null :
(Long) savedInstanceState.getSerializable(GoalDbTable.KEY_ROWID);
if (mRowId == null) {
Bundle extras = getIntent().getExtras();
mRowId = (extras != null) ? extras.getLong(GoalDbTable.KEY_ROWID)
: null;
}
populateFields();
finishBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setResult(RESULT_OK);
finish();
}
});
}
private void populateFields() {
if (mRowId != null) {
Cursor goal = mDbGoals.find(mRowId);
startManagingCursor(goal);
mName.setText(goal.getString(
goal.getColumnIndexOrThrow(GoalDbTable.KEY_NAME)));
}
}
@Override
protected void onResume() {
super.onResume();
populateFields();
}
I feel like the error is that it can't find GoalEdit (although it obviously can). Are there any obvious fubar's in my code (or other things I should check)?
Edit: Figured out how to use the debugger a bit better, had to press resume a few more times to show an exception.
Exceptions
ERROR/AndroidRuntime(741):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.rossmasters.mygoals/com.rossmasters.mygoals.GoalEdit}:
java.lang.RuntimeException:
Binary XML file line #9: You must supply a layout_width attribute.
I'm not sure which file that is referring to however, I've added layout_width's
to each item.