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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:46:06+00:00 2026-06-11T16:46:06+00:00

I am new to Android and Java development and am looking to implement a

  • 0

I am new to Android and Java development and am looking to implement a custom event, however having done lots of research and trying various different approaches i cannot seem to get it to work.

I am essentially trying to create a battle system, which i have implemented in .NET but cannot seem to get working in Java, it requires me to create events for things such as DealtDamage, DamageReceived, Died etc.

This will be inherteing information from the characters object which consits of thing such as hp, attack, defence etc.

Can someone please provide sample code how I can create these events and then action them in various classes.

e.g. Damage Dealt

user1 atk – user 2 def = totalatk
return totalatk

Thanks

  • 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-11T16:46:08+00:00Added an answer on June 11, 2026 at 4:46 pm

    If you are trying to generate callbacks from your class (raise events):

    In the class which generates the callback:

    public interface EventHappened{
            void callback(int arg1, String arg2);
    }
    
    ...
    
    ArrayList<EventHappened> eventHappenedObservers = new ArrayList<~>;
    
    ...
    
    public void setEventHappenedObserver(EventHappened observer){
         eventHappenedObservers.add(observer);
    }
    
    ...
    
    if (eventHasHappened){
        for (EventHappened eventHappenedObserver:eventHappenedObservers){
            eventHappendedObserver.callback(event.number,event.toString());
        }
    }
    
    ...
    

    In the consuming class:

    instanceOfClassRaisingCallback.setEventHappendedObserver(new EventHappened{
         @Override
         void callBack(int arg1, String arg2){
              doStuffWithArgs(arg1,arg2);
         }
       )};
    

    (from memory, apologies for typos and syntax errors but you get the idea…I hope)

    Good luck.

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

Sidebar

Related Questions

I'm fairly new to Android, but have done lots of Java/JSP development and HTML
I'm new to Android development in Java and Eclipse. I am trying to develop
New to both Android development and Java, trying to separate my queries into query
I am new to Java / Android development, and I am now trying to
I'm new to Java and Android development so bear with on this... I'm trying
I am very new to Android development and Java. Have read around but I'm
I am pretty new to android app development and java and I encountered the
I'm still relatively new to Java and Android development, so I'm still unfamiliar with
I am also new to Java and Android Development, been making a simple game
I am a little new to android/java. I am trying to pass JSON values

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.