Hi
I was trying out an example from one of the android books I have. It worked
fine earlier but when I tried to modify the textview and list view it
started force closing. The logcat output is as follows (relevant part):
06-13 15:48:33.338: ERROR/AndroidRuntime(453):
android.view.InflateException: Binary XML file line #2: Error inflating
class com.raghavsood.listdroid.ListDroidItemView
06-13 15:48:33.338: ERROR/AndroidRuntime(453): Caused by:
java.lang.ClassNotFoundException: com.raghavsood.listdroid.ListDroidItemView
in loader
dalvik.system.PathClassLoader[/data/app/com.ragahvsood.listdroid-1.apk]
06-13 17:16:09.262: ERROR/AndroidRuntime(477):
android.view.InflateException: Binary XML file line #2: Error inflating
class com.raghavsood.listdroid.ListDroidItemView
06-13 17:16:09.262: ERROR/AndroidRuntime(477): Caused by:
java.lang.ClassNotFoundException: com.raghavsood.listdroid.ListDroidItemView
in loader
dalvik.system.PathClassLoader[/data/app/com.ragahvsood.listdroid-1.apk]
The ListDroidViewClass is as follows:
package com.ragahvsood.listdroid;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.TextView;
public class ListDroidItemView extends TextView {
public ListDroidItemView (Context context, AttributeSet ats, int ds) {
super(context, ats, ds);
init();
}
public ListDroidItemView (Context context) {
super(context);
init();
}
public ListDroidItemView (Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private Paint marginPaint;
private Paint linePaint;
private int paperColor;
private float margin;
private void init() {
//Get reference to resource table
Resources myResources = getResources();
//Create paint brushes
marginPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
marginPaint.setColor(myResources.getColor(R.color.notepad_margin));
linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
linePaint.setColor(myResources.getColor(R.color.notepad_lines));
paperColor = myResources.getColor(R.color.notepad_paper);
margin = myResources.getColor(R.dimen.notepad_margin);
}
@Override
public void onDraw(Canvas canvas) {
//Color as paper
canvas.drawColor(paperColor);
//Draw ruled lines
canvas.drawLine(0, 0, getMeasuredHeight(), 0, linePaint);
canvas.drawLine(0, getMeasuredHeight(), getMeasuredWidth(),
getMeasuredHeight(), linePaint);
//Draw margin
canvas.drawLine(margin, 0, margin, getMeasuredHeight(), marginPaint);
//Move text
canvas.save();
canvas.translate(margin, 0);
//Use TextView to render text
super.onDraw(canvas);
canvas.restore();
}
}
The application is a to do list. There is an Edittext and a listview. The
force close occurs when you press enter to add the text from the edittext to
the listview. The app example was taken from Professional Android 2
Application Development. I am developing on a macbook pro, Java is installed
correctly.
Thanks
--
Raghav Sood
http://www.raghavsood.com/
http://www.androidappcheck.com/
http://www.telstop.tel/
--
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