package todomore.android;

import org.metawidget.android.widget.AndroidMetawidget;

import com.darwinsys.todo.model.Task;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

public class DetailsActivity extends Activity {

	private Task mTask;

	public void onCreate(Bundle saved) {
		super.onCreate(saved);
		setContentView(R.layout.details_activity);

		long id = getIntent().getLongExtra("taskId", -1);

		if (id != -1) {
			mTask = ((TodoMoreApplication) getApplication()).getTaskDao().findById(id);
		} else {
			mTask = new AndroidTask();
		}

		final AndroidMetawidget metawidget = 
			(AndroidMetawidget) findViewById(R.id.metawidget);
        metawidget.setToInspect(mTask);
        if ( id == -1) {
            metawidget.setReadOnly(false);
        }

        if (!metawidget.isReadOnly()) {
            metawidget.buildWidgets();
            View view = metawidget.findViewWithTag("name");
            view.setFocusable(true);
            view.setFocusableInTouchMode(true);
            view.requestFocus();
        }
	}
}

@@ -190,88 +190,399 @@
 oid.
-view.View;%0A%0Apublic class DetailsActivity extends Activity %7B%0A%0A%09private Task mTask
+util.Log;%0Aimport android.view.View;%0A%0A/** %0A * An Activity that shows all the Details of one Task, using MetaWidget.%0A * It starts in display mode, but an Edit button makes it editable.%0A * @author Ian Darwin%0A */%0Apublic class DetailsActivity extends Activity %7B%0A%0A%09private static final String TAG = DetailsActivity.class.getSimpleName();%0A%09private Task mTask;%0A%09private AndroidMetawidget mMetawidget
 ;%0A%0A%09
@@ -741,16 +741,44 @@
 %22, -1);%0A
+%09%09Log.d(TAG, %22_id = %22 + id);
 %0A%09%09if (i
@@ -919,49 +919,22 @@
 %0A%0A%09%09
-final AndroidMetawidget metawidget = %0A%09%09%09
+mMetawidget = 
 (And
@@ -981,32 +981,33 @@
 dget);%0A        m
+M
 etawidget.setToI
@@ -1033,17 +1033,16 @@
     if (
- 
 id == -1
@@ -1050,32 +1050,33 @@
  %7B%0A            m
+M
 etawidget.setRea
@@ -1114,16 +1114,17 @@
   if (!m
+M
 etawidge
@@ -1154,16 +1154,17 @@
        m
+M
 etawidge
@@ -1206,16 +1206,17 @@
 view = m
+M
 etawidge
@@ -1373,10 +1373,117 @@
    %7D%0A%09%7D%0A
+%09%0A%09public void enableEditing(View v) %7B%0A%09%09Log.d(TAG, %22enableEditing%22);%0A%09%09mMetawidget.setReadOnly(false);%0A%09%7D%0A
 %7D%0A

Make metawidget object a field so enableEditing() can find it