hi, there... I wrote CustomView Class, and load it in layout.
so i trid to find CustomView using findViewById() in activiy to get handle. but findViewById() was return null. I need your help . Written Code is like below: --------------------------------------------------------------------------------------------------------------------- main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="10dp" android:text="@string/hello" /> <com.test.MapCanvas android:id="@+id/map_canvas" android:layout_width="fill_parent" android:layout_height="100dp" android:focusable="true" android:clickable="true" /> </LinearLayout> --------------------------------------------------------------------------------------------------------------------- MapCanvas.java: package com.test; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.View; public class MapCanvas extends View { // ... public MapCanvas(Context context) { super(context); initialize(); } public MapCanvas(Context context, AttributeSet attrs) { super(context); initialize(); } private void initialize() { // ... } @Override protected void onDraw(Canvas canvas) { // ... } } --------------------------------------------------------------------------------------------------------------------- Test.java (Activity) package com.test; import android.app.Activity; import android.os.Bundle; import com.test.MapCanvas; public class Test extends Activity { /** Called when the activity is first created. */ private MapCanvas mapCanvas; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapCanvas = (MapCanvas)this.findViewById(R.id.map_canvas); // *** null return. } } --------------------------------------------------------------------------------------------------------------------- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en