Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:54:08+00:00 2026-06-08T13:54:08+00:00

I’m trying to create a custom view component which looks like this: a component

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:54:10+00:00Added an answer on June 8, 2026 at 1:54 pm

    Why not try to add the onClick listener from inside the MTMenuViewController class like

    ImageView menu = (ImageView)this.findViewById(R.id.imageMenu);
    menu.setOnClickListener(PUT THE LISTENER HERE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.