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

The Archive Base Latest Questions

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

I have app where it’s only a timer with a whole bunch of special

  • 0

I have app where it’s only a timer with a whole bunch of special methods in the main activity. This works great with no problems. Now, that I have it working, I’m trying to include it in a much more complicated application where I’m going to be inserting the timer in numerous places via fragments.

Should I include all of my special methods in my fragment activity? IE:

public class Timer_fragment extends android.support.v4.app.Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.timer_frag, container, false);
    }
    //SHOULD I insert my special methods here?
}

or should I include them in my main?

I’m asking because I’ve tried both ways, and the fragment activity way gave me errors in java, but putting them in my main gave me errors during runtime. Basically I have a timer that runs great as a standalone application, but I’m trying to convert it into a fragment, so that I can plug it into multiple places in my app.

Examples of “special methods”:
I take a view in the layout and update it according to the new numbers inputted on the timer. These methods require the view to be inflated before they can be used.

Note: The errors at runtime I am experiencing are nullPointerExceptions.

  • 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-08T17:54:27+00:00Added an answer on June 8, 2026 at 5:54 pm

    The idea behind a Fragment is that it is a resuable section (ie fragment) of an Activity that can be used in other Activities, or even in the same Activity but with the addition or absence of other Fragments.

    In the Gmail app for example, the list of all emails in an inbox is one Fragment, and the actual contents of an email is another Fragment. On a tablet in landscape mode, both are shown. A phone in portrait mode, however, will only show one of the two Fragments at once.

    Thus each Fragment should encapsulate all functionality and UI components necessary to use that Fragment. This means that all of your “special” methods such as inflating the Fragment’s view XML should happen within the Fragment.

    The Activity (or Activities) that utilize the Fragment should only need to use a FragmentManager (or similar method) to add your Fragment to the Activity’s layout. The parent Activity of a Fragment should also handle communication between Fragments and other components such as other Activities, Fragments, or Threads.

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

Sidebar

Related Questions

we have app hosted on google app engine for java. In this app we
We have App A as main app. Now we build from it App B
I have app that works perfectly fine on my Phone (desire HD). When I
I need show PIN Code activity after that (we have App with many Activities):
I have app in which I used soundmanager with 26 sounds. It works fine
Background: We have app a, b, and plan to add more apps into this
is it possible to have app.config file like this : <?xml version=1.0 encoding=utf-8 ?>
I have app that uses ClickOnce deployment. It works on about a dozen machines
OK I have app for iPad that reads magazines. All previous issues works fine.
I have an express app that has a bunch of static javascript files that

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.