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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:00:53+00:00 2026-06-11T08:00:53+00:00

I have a Fragment, which should execute a (public) Method reset() from the Activity

  • 0

I have a Fragment, which should execute a (public) Method reset() from the Activity in the Fragment it is called from.

I found, for example, this page:
Calling Activity methods from Fragment
The other way there’s no problem:

Input_tap Input_tap = (Input_tap) getFragmentManager().findFragmentById(R.id.input);
Input_tap.reset();

Does someone has any idea how to do it the other way?
and: Does the Method has to be public – its a “void” Method?

  • 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-11T08:00:55+00:00Added an answer on June 11, 2026 at 8:00 am

    A Fragment can call getActivity() to retrieve the activity that is hosting it.

    If there is only one possible activity that can host the fragment, just cast the Activity to the proper class (e.g., MyActivity) and call a method on it:

    ((MyActivity)getActivity()).someMethod();
    

    If there might be more than one activity that can host the fragment, you are best served by implementing a common interface on all those activities, so you can cast getActivity()‘s result to that interface:

    ((MyInterface)getActivity()).someMethod();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say you have a fragment of the page which displays the most recent
I have an Activity which uses a Fragment . I simply want to pass
In my application, I have a Fragment which is attached to the main activity
In my Android application, I have a fragment activity which it has a progressbar.
I have an activity which does a fragment transaction DetailFragment newFragment = new DetailFragment();
When creating an Android application using Loaders, should every activity and fragment have its
I have a HTML fragment which contains two anchor tags in various parts of
I have a fragment of html which is contained in a property of a
I have a xsl:variable ($features-list) specified in my XSL which contains a tree fragment
I have fragment that on a component click pop-ups DialogFragment. This dialog fragment holds

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.