I created a class like this
public final class MyView extends View {
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
[...]
}
[...]
}
and then I want to use it within my layout.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.hitziger.barcode.MyView
android:id="@+id/my_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
But Eclipse tells me in the error log
AndroidManifest: Ignoring unknown 'com.hitziger.barcode.MyView' XML element
How can I make MyView accessable within a layout? Do I have to publish this class elsewhere?
Creating custom views. By extending the View class or one of its subclasses you can create your custom view. For drawing view use the onDraw() method. In this method you receive a Canvas object which allows you to perform drawing operations on it, e.g. draw lines, circle, text or bitmaps.
Create a custom viewGo to View > Workbook Views > Custom Views > Add. In the Name box, type a name for the view. Tip: To make a view easier to identify, you can include the name of the active worksheet in the name of a view. Under Include in view, select the check boxes of the settings that you want to include.
Custom Views is just a way to make an android developer a painter. When you need to create some custom and reuse the views when it is not provided by the Android Ecosystem. Custom Views can be used as widgets like TextView, EditText etc.
Android provides a series of different layouts to suit your apps needs. One of the quickest and easiest ways to display information to users is via the ListView component. This component creates a simple scrollable region that can display unique sets of information.
You should write it like:
<view class="com.hitziger.barcode.MyView"...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With