I'm trying to create a custom view component which looks like this: a component will work as a menu - it has 4 imageviews inside which react to onClick event. I made a separate .xml with them and a class for it. Than i set the parent node class from .xml "class = 'myclass'". In my .xml an imageview has a onClick declared, but when i try to handle it using myclass - application crashes. What is wrong? Or I suppose the main question is: what is a right way to set event handlers for a custom view?Handlers which are in this views class definition. Should I write in .xml of a view something like
Addition: how do I, then, can fire events from this custom view for activity which will hold it to handle?
Here is my menu .xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
class="com.example.mtgesturestest.MTMenuViewController"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/main_layout" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/imageChannels"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/channels"
android:layout_marginBottom="10dp" />
<ImageView
android:id="@+id/imageMessages"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/messages"
android:layout_marginBottom="10dp" />
<ImageView
android:id="@+id/imageTimeline"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/timeline"
android:onClick="yell"
android:layout_marginBottom="10dp" />
</RelativeLayout>
<ImageView
android:id="@+id/imageMenu"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/menu"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-15dp"
android:onClick="maximizeMenu"/>
</RelativeLayout>
Application says it cant find onClick handler (maximizeMenu), but its searching it in the activity where I add this view instead of com.mtgesturestest.MTMenuViewController class. I want this menu to be independent. It should handle click, play some animation and then fire event for parent activity. So you can say that this onClick here is for inner use of my custom view.