Hi:
I am trying to use my customer view and got the following error. I
wonder if anyone can give me some advice. Thanks.
I/ActivityManager( 50): Starting activity: Intent { comp=
{com.example.android.
apis/com.example.android.apis.view.ChiralList} }
D/AndroidRuntime( 381): Shutting down VM
W/dalvikvm( 381): threadid=3: thread exiting with uncaught exception
(group=0x4
0010e28)
E/AndroidRuntime( 381): Uncaught handler: thread main exiting due to
uncaught e
xception
E/AndroidRuntime( 381): java.lang.RuntimeException: Unable to start
activity Co
mponentInfo{com.example.android.apis/
com.example.android.apis.view.ChiralList}:
android.view.InflateException: Binary XML file line #24: Error
inflating class c
om.example.android.apis.view.ChiralView
E/AndroidRuntime( 381): at
android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2140)
E/AndroidRuntime( 381): at
android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2156)
E/AndroidRuntime( 381): at android.app.ActivityThread.access
$1800(Activi
tyThread.java:112)
E/AndroidRuntime( 381): at android.app.ActivityThread
$H.handleMessage(Ac
tivityThread.java:1580)
E/AndroidRuntime( 381): at android.os.Handler.dispatchMessage
(Handler.ja
va:88)
E/AndroidRuntime( 381): at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime( 381): at android.app.ActivityThread.main
(ActivityThrea
d.java:3742)
E/AndroidRuntime( 381): at
java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 381): at java.lang.reflect.Method.invoke
(Method.java:5
15)
E/AndroidRuntime( 381): at com.android.internal.os.ZygoteInit
$MethodAndA
rgsCaller.run(ZygoteInit.java:739)
E/AndroidRuntime( 381): at
com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:497)
E/AndroidRuntime( 381): at dalvik.system.NativeStart.main
(Native Method)
E/AndroidRuntime( 381): Caused by: android.view.InflateException:
Binary XML fi
le line #24: Error inflating class
com.example.android.apis.view.ChiralView
E/AndroidRuntime( 381): at
android.view.LayoutInflater.createView(Layout
Inflater.java:502)
E/AndroidRuntime( 381): at
android.view.LayoutInflater.createViewFromTag
(LayoutInflater.java:564)
E/AndroidRuntime( 381): at android.view.LayoutInflater.rInflate
(LayoutIn
flater.java:617)
E/AndroidRuntime( 381): at android.view.LayoutInflater.inflate
(LayoutInf
later.java:407)
E/AndroidRuntime( 381): at android.view.LayoutInflater.inflate
(LayoutInf
later.java:320)
E/AndroidRuntime( 381): at android.view.LayoutInflater.inflate
(LayoutInf
later.java:276)
E/AndroidRuntime( 381): at
com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:227)
E/AndroidRuntime( 381): at android.app.Activity.setContentView
(Activity.
java:1569)
E/AndroidRuntime( 381): at
com.example.android.apis.view.ChiralList.onCr
eate(ChiralList.java:69)
E/AndroidRuntime( 381): at
android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1122)
E/AndroidRuntime( 381): at
android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2103)
E/AndroidRuntime( 381): ... 11 more
E/AndroidRuntime( 381): Caused by: java.lang.NoSuchMethodException:
ChiralView
E/AndroidRuntime( 381): at
java.lang.Class.getMatchingConstructor(Class.
java:537)
E/AndroidRuntime( 381): at java.lang.Class.getConstructor
(Class.java:401
)
E/AndroidRuntime( 381): at
android.view.LayoutInflater.createView(Layout
Inflater.java:474)
E/AndroidRuntime( 381): ... 21 more
My customer view class is
public class ChiralView extends View {
public ChiralView(Context context) {
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
setLongClickable(true);
Log.i(getClass().getSimpleName(), "in ChiralView constructor
()");
}
.
.
.
}
The main.xml file is
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<com.example.android.apis.view.ChiralView
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:id="@+id/llayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/textstatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dip"
android:paddingRight="8dip"/>
</LinearLayout>
</com.example.android.apis.view.ChiralView>
</LinearLayout>
Error was thrown from program
public class ChiralList extends Activity{
//implements View.OnTouchListener {
private TextView mList;
private ChiralView mChiral;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mList = (TextView)findViewById(R.id.textstatus);
mChiral = (ChiralView)findViewById(R.id.scrollview);
ArrayAdapter<CharSequence> listAdapter = new
ArrayAdapter<CharSequence>(this, R.id.textstatus, DATA);
int itemCount = listAdapter.getCount();
for(int i = 0; i < itemCount; i++){
mList.append(listAdapter.getItem(i) + "\n");
}
// Null tag means the view has the correct data
mList.setTag(null);
Log.i(getClass().getSimpleName(), "in ChiralList onCreate
()");
}
.
.
.
}
AX
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---