Best code examples for Fragment isVisible method (

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Fragment isVisible method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Fragment isVisible examples from Open Source projects
This code example shows how to use the following methods: dismiss, isVisible
66:	if (fragment != null && fragment.isVisible()) { 
67:	fragment.dismiss(); 
Full Snippet Info
This code example shows how to use the following methods: show, isVisible
150:	if (!dialog.isVisible()) { 
151:, "SetReportNoticeDialog"); 
Full Snippet Info
Related Fragment isVisible Questions & Answers:
A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity. Interaction with fragments is done through FragmentManager, which can be obtained via Activity.getFragmentManager() and Fragment.getFragmentManager().

The Fragment class can be used many ways to achieve a wide variety of results. In its core, it represents a particular operation or interface that is running within a larger Activity. A Fragment is closely tied to the Activity it is in, and can not be used apart from one. Though Fragment defines its own lifecycle, that lifecycle is dependent on its activity: if the activity is stopped, no fragments inside of it can be started; when the activity is destroyed, all fragments will be destroyed. All subclasses of Fragment must include a public empty constructor. The framework will often re-instantiate a fragment class when needed, in particular during state restore, and needs to be able to find this constructor to instantiate it. If the empty constructor is not available, a runtime exception will occur in some cases during state restore. Topics covered here: Older Platforms Lifecycle Layout Back Stack Developer Guides For more information about using fragments, read the Fragments developer guide. Older Platforms While the Fragment API was introduced in HONEYCOMB, a version of the API at is also available for use on older platforms through FragmentActivity. See the blog post Fragments For All for more details. Lifecycle Though a Fragment's lifecycle is tied to its owning activity, it has its own wrinkle on the standard activity lifecycle. It includes basic activity lifecycle methods such as onResume(), but also important are methods related to interactions with the activity and UI generation. The core series of lifecycle methods that are called to bring a fragment up to resumed state (interacting with the user) are: onAttach(Activity) called once the fragment is associated with its activity. onCreate(Bundle) called to do initial creation of the fragment. onCreateView(LayoutInflater, ViewGroup, Bundle) creates and returns the view hierarchy associated with the fragment. onActivityCreated(Bundle) tells the fragment that its activity has completed its own Activity.onCreate(). onViewStateRestored(Bundle) tells the fragment that all of the saved state of its view hierarchy has been restored. onStart() makes the fragment visible to the user (based on its containing activity being started). onResume() makes the fragment interacting with the user (based on its containing activity being resumed). As a fragment is no longer being used, it goes through a reverse series of callbacks: onPause() fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity. onStop() fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity. onDestroyView() allows the fragment to clean up resources associated with its View. onDestroy() called to do final cleanup of the fragment's state. onDetach() called immediately prior to the fragment no longer being associated with its activity. Layout Fragments can be used as part of your application's layout, allowing you to better modularize your code and more easily adjust your user interface to the screen it is running on. As an example, we can look at a simple program consisting of a list of items, and display of the details of each item.An activity's layout XML can include tags to embed fragment instances inside of the layout. For example, here is a simple layout that embeds one fragment:The layout is installed in the activity in the normal way:The titles fragment, showing a list of titles, is fairly simple, relying on ListFragment for most of its work. Note the implementation of clicking an item: depending on the current activity's layout, it can either create and display a new fragment to show the details in-place (more about this later), or start a new activity to show the details.The details fragment showing the contents of a selected item just displays a string of text based on an index of a string array built in to the app:In this case when the user clicks on a title, there is no details container in the current activity, so the titles fragment's click code will launch a new activity to display the details fragment:However the screen may be large enough to show both the list of titles and details about the currently selected title. To use such a layout on a landscape screen, this alternative layout can be placed under layout-land:Note how the prior code will adjust to this alternative UI flow: the titles fragment will now embed the details fragment inside of this activity, and the details activity will finish itself if it is running in a configuration where the details can be shown in-place. When a configuration change causes the activity hosting these fragments to restart, its new instance may use a different layout that doesn't include the same fragments as the previous layout. In this case all of the previous fragments will still be instantiated and running in the new instance. However, any that are no longer associated with a tag in the view hierarchy will not have their content view created and will return false from isInLayout(). (The code here also shows how you can determine if a fragment placed in a container is no longer running in a layout with that container and avoid creating its view hierarchy in that case.) The attributes of the tag are used to control the LayoutParams provided when attaching the fragment's view to the parent container. They can also be parsed by the fragment in onInflate(Activity, AttributeSet, Bundle) as parameters. The fragment being instantiated must have some kind of unique identifier so that it can be re-associated with a previous instance if the parent activity needs to be destroyed and recreated. This can be provided these ways: If nothing is explicitly supplied, the view ID of the container will be used. android:tag can be used in to provide a specific tag name for the fragment. android:id can be used in to provide a specific identifier for the fragment. Back Stack The transaction in which fragments are modified can be placed on an internal back-stack of the owning activity. When the user presses back in the activity, any transactions on the back stack are popped off before the activity itself is finished. For example, consider this simple fragment that is instantiated with an integer argument and displays that in a TextView in its UI:A function that creates a new instance of the fragment, replacing whatever current fragment instance is being shown and pushing that change on to the back stack could be written as: void addFragmentToStack() { mStackLevel++; // Instantiate a new fragment. Fragment newFragment = CountingFragment.newInstance(mStackLevel); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(, newFragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commit(); } After each call to this function, a new entry is on the stack, and pressing back will pop it to return t...
isVisible Method Overview
Return true if the fragment is currently visible to the user.
See Also
  • getActivity
    Return the Activity this fragment is currently associated with.
  • getArguments
    Return the arguments supplied when the fragment was instantiated, if any.
  • getChildFragmentManager
    Return a private FragmentManager for placing and managing Fragments inside of this Fragment.
  • getFragmentManager
    Return the FragmentManager for interacting with fragments associated with this fragment's activity.
  • getId
    Return the identifier this fragment is known by.
  • getLoaderManager
    Return the LoaderManager for this fragment, creating it if needed.
  • getString
    Return a localized string from the application's package's default string table.
  • getTag
    Get the tag name of the fragment, if specified.
  • getView
    Get the root view for the fragment's layout (the one returned by onCreateView(LayoutInflater, ViewGroup, Bundle)), if provided.
  • instantiate
    Like instantiate(Context, String, Bundle) but with a null argument Bundle.
  • isAdded
    Return true if the fragment is currently added to its activity.
  • isDetached
    Return true if the fragment has been explicitly detached from the UI.
  • onActivityCreated
    Called when the fragment's activity has been created and this fragment's view hierarchy instantiated.
  • onActivityResult
    Receive the result from a previous call to startActivityForResult(Intent, int).
  • onAttach
    Called when a fragment is first attached to its activity.
  • onConfigurationChanged
    Called by the system when the device configuration changes while your component is running.
  • onCreate
    Called to do initial creation of a fragment.
  • onCreateView
    Called to have the fragment instantiate its user interface view.
  • onDestroy
    Called when the fragment is no longer in use.
  • onDestroyView
    Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment.
  • onDetach
    Called when the fragment is no longer attached to its activity.
  • onPause
    Called when the Fragment is no longer resumed.
  • onResume
    Called when the fragment is visible to the user and actively running.
  • onSaveInstanceState
    Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance of its process is restarted.
  • onStart
    Called when the Fragment is visible to the user.
  • onStop
    Called when the Fragment is no longer started.
  • onViewCreated
    Called immediately after onCreateView(LayoutInflater, ViewGroup, Bundle) has returned, but before any saved state has been restored in to the view.
  • setArguments
    Supply the construction arguments for this fragment.
  • setHasOptionsMenu
    Report that this fragment would like to participate in populating the options menu by receiving a call to onCreateOptionsMenu(Menu, MenuInflater) and related methods.
  • setRetainInstance
    Control whether a fragment instance is retained across Activity re-creation (such as from a configuration change).
  • setUserVisibleHint
    Set a hint to the system about whether this fragment's UI is currently visible to the user.
  • startActivity
    Call startActivity(Intent) from the fragment's containing Activity.
  • toString
    Returns a string containing a concise, human-readable description of this object.