Hi, I want to create an experimental custom component which consists
of just one EditText and one TextView. So I did this:

package com.customcomponent;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.AbsoluteLayout;
import android.widget.EditText;
import android.widget.TextView;

class CustomEditText extends AbsoluteLayout {

        EditText editText;
        TextView textView;
         CustomEditText(Activity activity) {
                super(activity);
                textView= (TextView)activity.findViewById(R.id.textView);

                Log.v("CustomEditText constructor","initialized textView");
                editText= (EditText)activity.findViewById(R.id.editText);
                Log.v("CustomEditText constructor","initialized editText");
                // TODO Auto-generated constructor stub
        }


public void setItem1 (CharSequence charSequence){
 editText.setText(charSequence);
 Log.v("CustomEditText setItem","set textView");
 textView.setText(charSequence);
 Log.v("CustomEditText setItem","set editText");

}


}


My XML file looks like:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/absoluteLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android";
>


<EditText
android:id="@+id/editText"
android:layout_width="316px"
android:layout_height="228px"
android:text="EditText"
android:textSize="18sp"
android:layout_x="3px"
android:layout_y="5px"
/>

<TextView
android:id="@+id/textView"
android:layout_width="312px"
android:layout_height="181px"
android:text="TextView"
android:layout_x="5px"
android:layout_y="234px"
/>


</AbsoluteLayout>

I create an object of the custom component in my main class, I have
tried constructing is:
customEditText = new CustomEditText (this);

and
customEditText =
(CustomEditText)this.findViewById(R.layout.component);

even though I can construct, the setItem function gives a null pointer
exception.

Thanks,
Sylvester

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to