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 8734231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:48:06+00:00 2026-06-13T09:48:06+00:00

Possible Duplicate: How to Define Callbacks in Android? I was reading through the Internet

  • 0

Possible Duplicate:
How to Define Callbacks in Android?

I was reading through the Internet about Callbacks and I understand that this has heavy weightage in an Android Ecosystem.

Can anyone state an example and explain what are callbacks are how do they work?

  • 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-13T09:48:07+00:00Added an answer on June 13, 2026 at 9:48 am

    Do you mean callback using interface?
    if yes here’s an example

    this is callbackmenu.java

    package com.example.test.callback;
    
    public interface CallbackCalendar {
        public void onClick();
    }
    

    this is an example how you implement it

    public class CallbackCell implements CallbackCalendar{
    
        @Override
        public void onClick() {
            Log.i("TAG", "IT WORKS!);
            addChild(2);
        }
    }
    

    this is an example that will allow you to access a view from another view
    like what I use in my calendar library, I create 3 view classes, calendar View, calendar row, calendar cell

    with passing this callback from calendar view to calendar cell we can add view,set value or anything else in the calendar view from the calendar cell (calendar cell is a part of calendar row and calendar row is a part of calendar view) in this example I’m trying to set whenever the user click the cell we will add another view in the calendar view (main view)

    this is the example of using callback in the calendar cell

    public CalendarCell(Context context,int day,final CallbackCalendar callback)
    {
        super(context);
        final int temp = day;
        this.context = context;
        this.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
        LinearLayout.LayoutParams lpCalendarCell = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        lpCalendarCell.weight = 1;
        this.setLayoutParams(lpCalendarCell);
        this.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                callback.onClick();
            }
        });
        addContainer(day);
    }
    

    so I set the callback in the calendar view and pass it to the calendar row and pass it again to the calendar cell and call the onClick in the calendar cell

    I think that’s all if you have any question feel free to write in the comment 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Define a method that has many (or infinite) arguments I have the
Possible Duplicate: Meaning of U suffix I'm going through code that has a bunch
Possible Duplicate: The written versions of the logical operators. I notice that C++ define
Possible Duplicate: Problem with Macros Hi all I have defined this macro: #define SQ(a)
Possible Duplicate: Conditional “Browsable” Attribute I define AppSettings class that have a few properties.
Possible Duplicate: “static const” vs “#define” in c When I do this : #define
Possible Duplicate: Detecting CPU architecture compile-time Is there a define that GCC sets which
Possible Duplicate: Why 'defined() || define()' syntax in defining a constant This piece of
Possible Duplicate: “static const” vs “#define” in c I am going through the K&R
Possible Duplicate: Define a generic that implements the + operator I am recently working

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.