The logcat says: 06-17 11:55:19.280: ERROR/AndroidRuntime(359): *java.lang.NullPointerException* 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at android.graphics.Canvas.drawRoundRect(Canvas.java:938) 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at *com.es.TransparentPanel.dispatchDraw(TransparentPanel.java:53) * Your code calls canvas.drawRoundRect with something that's null.
Specifically, it's the paint object. It's null because you code doesn't call init() from the first constructor. And the first constructor is what's used for loading views from XML. Whenever you see the "Auto-generated constructor stub" comment, it's a hint to examine the code and make sure it makes sense. The "TODO" is there to remind about this, and shows in Eclipse's task view. -- Kostya 2011/6/17 ABSOLUT <[email protected]> > Many thanks! I don't notice that :-( > > Now I have other error but I cant understand why: > > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): FATAL EXCEPTION: main > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): > java.lang.NullPointerException > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.graphics.Canvas.drawRoundRect(Canvas.java:938) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > com.es.TransparentPanel.dispatchDraw(TransparentPanel.java:53) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewGroup.drawChild(ViewGroup.java:1644) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.View.draw(View.java:6883) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.widget.FrameLayout.draw(FrameLayout.java:357) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewGroup.drawChild(ViewGroup.java:1646) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewGroup.drawChild(ViewGroup.java:1644) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.View.draw(View.java:6883) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.widget.FrameLayout.draw(FrameLayout.java:357) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > com.android.internal.policy.impl.PhoneWindow > $DecorView.draw(PhoneWindow.java:1862) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewRoot.draw(ViewRoot.java:1522) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewRoot.performTraversals(ViewRoot.java:1258) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.view.ViewRoot.handleMessage(ViewRoot.java:1859) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.os.Handler.dispatchMessage(Handler.java:99) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.os.Looper.loop(Looper.java:123) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > android.app.ActivityThread.main(ActivityThread.java:3683) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > java.lang.reflect.Method.invokeNative(Native Method) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > java.lang.reflect.Method.invoke(Method.java:507) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > com.android.internal.os.ZygoteInit > $MethodAndArgsCaller.run(ZygoteInit.java:839) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) > 06-17 11:55:19.280: ERROR/AndroidRuntime(359): at > dalvik.system.NativeStart.main(Native Method) > > My custom relativelayout is: > > package com.es; > > import android.content.Context; > > public class TransparentPanel extends RelativeLayout { > > private Paint innerPaint, borderPaint; > > > public TransparentPanel(Context context, AttributeSet attrs) { > super(context, attrs); > // TODO Auto-generated constructor stub > } > > public TransparentPanel (Context context) { > super(context); > init(); > } > > > private void init() { > innerPaint = new Paint(); > innerPaint.setARGB(225, 75, 75, 75); //gray > innerPaint.setAntiAlias(true); > > borderPaint = new Paint(); > borderPaint.setARGB(255, 255, 255, 255); > borderPaint.setAntiAlias(true); > borderPaint.setStyle(Style.STROKE); > borderPaint.setStrokeWidth(2); > } > > public void setInnerPaint(Paint innerPaint) { > this.innerPaint = innerPaint; > } > > public void setBorderPaint(Paint borderPaint) { > this.borderPaint = borderPaint; > } > > @Override > protected void dispatchDraw(Canvas canvas) { > > RectF drawRect = new RectF(); > drawRect.set(0,0, getMeasuredWidth(), getMeasuredHeight()); > > canvas.drawRoundRect(drawRect, 5, 5, innerPaint); > canvas.drawRoundRect(drawRect, 5, 5, borderPaint); > > super.dispatchDraw(canvas); > } > > } > > Could you help me? Many thanks again > > > On 17 jun, 11:17, Kostya Vasilyev <[email protected]> wrote: > > The layout inflater is unable to find your transparent panel class. > > > > Make sure the class name is correct, and that the class is public. > > > > -- > > Kostya Vasilyev > > 17.06.2011 12:01 пользователь "ABSOLUT" <[email protected]> написал: > > > > > Hi, > > > I'm trying to make a custom relativelayout but when I start the > > > activity it fails: > > > > > 06-17 09:57:23.253: ERROR/AndroidRuntime(526): > > > java.lang.RuntimeException: Unable to start activity > > > ComponentInfo{com.es/com.es.KkActivity}: > > > android.view.InflateException: Binary XML file line #4: Error > > > inflating class com.es.kk.TransparentPanel > > > 06-17 09:57:23.253: ERROR/AndroidRuntime(526): Caused by: > > > android.view.InflateException: Binary XML file line #4: Error > > > inflating class com.es.kk.TransparentPanel > > > 06-17 09:57:23.253: ERROR/AndroidRuntime(526): Caused by: > > > java.lang.ClassNotFoundException: com.es.kk.TransparentPanel in loader > > > dalvik.system.PathClassLoader[/data/app/com.es-2.apk] > > > ...... > > > > > My layout is: > > > > > <?xml version="1.0" encoding="utf-8"?> > > > <!-- Broadcast Receiver que hay que definir para la actualizacion del > > > widget --> > > > <!-- <RelativeLayout xmlns:android=" > http://schemas.android.com/apk/res/ > > > android" --> > > > <com.es.kk.TransparentPanel xmlns:android="http://schemas.android.com/ > > > apk/res/android" > > > android:id="@+id/relativo" > > > android:layout_width="wrap_content" > > > android:layout_height="wrap_content" > > > > <ImageView android:id="@+id/imagenWidget" > > > android:src="@drawable/tv" > > > android:layout_height="fill_parent" > > > android:layout_alignParentLeft="true" android:layout_width="42dip"/> > > > <ImageView android:id="@+id/barra" > > > android:src="@drawable/vertical" > > > android:layout_height="100dip" > > > android:layout_toRightOf="@id/imagenWidget" > > > android:layout_width="5dip"/> > > > <TextView android:id="@+id/textoWidget" > > > android:layout_toRightOf="@id/barra" android:layout_height="50dip" > > > android:gravity="center" android:layout_width="50dip" > > > android:inputType="textMultiLine" android:textSize="8sp"> > > > </TextView> > > > <ImageView android:id="@+id/barrahor" > > > android:src="@drawable/vvh" > > > android:layout_toRightOf="@id/barra" > > > android:layout_below="@+id/textoWidget" android:layout_width="50dip" > > > android:layout_height="wrap_content" android:adjustViewBounds="true"/> > > > <Button android:id="@+id/btnborrarCron" > > > android:layout_below="@+id/barrahor" android:layout_toRightOf="@id/ > > > barra" android:background="@drawable/custom_widget_button" > > > android:layout_height="match_parent" android:drawableLeft="@drawable/ > > > borrado" android:layout_width="50dip" android:textSize="8sp" > > > android:layout_centerVertical="true" android:gravity="center_vertical" > > > android:paddingLeft="10dip"> > > > </Button> > > > <ImageView android:id="@+id/barra2" > > > android:src="@drawable/vertical" > > > android:layout_height="100dip" > > > android:layout_toRightOf="@id/textoWidget" > > > android:layout_width="5dip"/> > > > <Button android:id="@+id/textoWidgetCron" > > > android:layout_toRightOf="@id/barra2" android:text="hola" > > > android:background="@drawable/custom_widget_button" > > > android:layout_height="fill_parent" android:gravity="center" > > > android:paddingTop="2dip" android:layout_width="match_parent" > > > android:textSize="8sp"> > > > </Button> > > > </com.es.kk.TransparentPanel> > > > > > Could you help me please? > > > Many thanks and sorry for my english! > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to > [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > > > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

