tags:

views:

73

answers:

1

CoreStartHere.java

 public class CoreStartHere extends TabActivity {

    :
 t = getTabHost();
 t.newTabSpec("tTask");
 t.setIndicator(...);
 t.setContent(new Intent().setClass(this, T1Task.class);
 :

}

t1Task.java

    T1Task extends Activity {

 :
 onCreate(Bundle ...) {

  :
  myListview = (ListView) findViewById(R.id.hdListView);
  myEditText = (EditText) findViewById(R.id.hdEditText);
  hdItems  = newArrayList <String>();
  aa = new ArrayAdapter <String>(this, R.layout.hditemview, hdItems);
  :

  setOnKeyListener (new OnKeyListener() {

   onKey(...) {

    :
    hdItems.add(0, myEditText.getText().toString());
    aa.notifyDatasetChanged();
    :
   }
  }


 }
}

hditemview.xml

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
 class="com.a1.hd.hdRecordTaskListItemView"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:padding="10dp"
 android:scrollbars="vertical"
 android:textColor="@color/HD_Text"
 android:fadingEdge="vertical"
 />

hdRecordTaskListItemView.java

    hdRecordTaskListItemView extends TextView {

 // has 3 constructors

 // onDraw

}

None of the constructor in hdRecordTaskListItemView get invoked and not surprisingly onDraw does not get called either. What is missing? - any suggestions or questions - please let me know. The text appears with the default style. The onDraw is supposed to draw on the "canvas". Thank you

A: 

You have to create the layout this way:

<com.a1.hd.hdRecordTaskListItemView xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:padding="10dp"
 android:scrollbars="vertical"
 android:textColor="@color/HD_Text"
 android:fadingEdge="vertical"
 />

While building a layout via an XML file you use elments like EditText, TextView and the like, you don't have to provide their complete name (e.g. android.widget.TextView) as android will recognize them; but, when you define your own views you have to indicate the complete name of the class you want to show, in this case com.a1.hd.hdRecordTaskListItemView.

Cristian
thank you - that worked!Pardon my ignorance - why is it done this way? - a link will be immensely helpful. What is it called? thanks again
Abhi
OK, I'll update my answer so that it gets more complete.
Cristian
got it! - it is namespace. thanks again
Abhi