Hi,
I am trying to create a custom control which does nothing except decorate the text which is displayed. When I reference this class inside the main.xml like all the examples which I am reading and deploy this to the emulator, the widget just says "Problem Loading Widget."
I am beginning Android development and just trying to understand how to dev custom controls:
This is the ExtendedTextView control:
package uk.co.andrewrea.android;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
public class ExtendedTextView extends TextView {
public ExtendedTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public ExtendedTextView(Context context, AttributeSet attrs){
super(context,attrs);
}
public ExtendedTextView(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
}
@Override
public CharSequence getText() {
// TODO Auto-generated method stub
return "***" + super.getText() + "***";
}
}
And this is main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="@drawable/widget_bg_normal"
android:layout_gravity="center"
android:layout_height="wrap_content">
<uk.co.andrewrea.android.ExtendedTextView android:id="@+id/widget_textview"
android:text="@string/hello"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal|center"
android:layout_marginTop="5dip"
android:padding="10dip"
android:textColor="@android:color/black"/>
</LinearLayout>
Cheers,
Andrew