Android: Custom TextView Inflate Exception -


i have created custom textview , thing did put 1 "instance" in layout xml. causes crash app "inflate exception" :

here's complete custom class (actually there nothing "custom" in yet...):

 package com.example.testapp; ... public  class mytextview extends textview {  public mytextview (context context) {     super(context); }  @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) {     super.onmeasure(widthmeasurespec, heightmeasurespec);        }   @override public void ondraw(canvas canvas) {      super.ondraw(canvas);  } 

}

the complete layout file:

<?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">  <com.example.testapp.mytextview     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="hello world, myactivity"     /> </linearlayout> 

the log is:

java.lang.runtimeexception: unable start activity  componentinfo{com.example.testapp/com.example.testapp.myactivity}:  android.view.inflateexception: binary xml file line #8: error inflating class  com.example.testapp.mytextview     @ android.app.activitythread.performlaunchactivity(activitythread.java:1651)     @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667)     @ android.app.activitythread.access$1500(activitythread.java:117)     @ android.app.activitythread$h.handlemessage(activitythread.java:935)     @ android.os.handler.dispatchmessage(handler.java:99)     @ android.os.looper.loop(looper.java:130)     @ android.app.activitythread.main(activitythread.java:3691)     @ java.lang.reflect.method.invokenative(native method)     @ java.lang.reflect.method.invoke(method.java:507)     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:912)     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:670)     @ dalvik.system.nativestart.main(native method) 

i have read through many posts these inflate exceptions, time it's easist case. class path used in xml (com.example.testapp.mytextview) seems correct - intellj idea suggested it...

btw: min target sdk version set 10.

add constructor this

public mytextview(context context, attributeset attrs) {     super(context, attrs); } 

hope helps


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -