Android APIs
public class

VerticalGridFragment

extends Fragment
java.lang.Object
   ↳ android.app.Fragment
     ↳ android.support.v17.leanback.app.VerticalGridFragment

Class Overview

A fragment for creating leanback vertical grids.

Renders a vertical grid of objects given a VerticalGridPresenter and an ObjectAdapter.

Summary

[Expand]
Inherited Constants
From interface android.content.ComponentCallbacks2
Public Constructors
VerticalGridFragment()
Public Methods
ObjectAdapter getAdapter()
Returns the object adapter.
Drawable getBadgeDrawable()
Returns the badge drawable.
VerticalGridPresenter getGridPresenter()
Returns the grid presenter.
OnItemClickedListener getOnItemClickedListener()
Returns the item clicked listener.
int getSearchAffordanceColor()
Returns the color used to draw the search affordance.
String getTitle()
Returns the title for the fragment.
View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Called to have the fragment instantiate its user interface view.
void onDestroyView()
Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment.
void onStart()
Called when the Fragment is visible to the user.
void onViewCreated(View view, Bundle savedInstanceState)
Called immediately after onCreateView(LayoutInflater, ViewGroup, Bundle) has returned, but before any saved state has been restored in to the view.
void setAdapter(ObjectAdapter adapter)
Sets the object adapter for the fragment.
void setBadgeDrawable(Drawable drawable)
Sets the badge drawable displayed in the title area.
void setGridPresenter(VerticalGridPresenter gridPresenter)
Sets the grid presenter.
void setOnItemClickedListener(OnItemClickedListener listener)
Sets an item clicked listener.
void setOnItemSelectedListener(OnItemSelectedListener listener)
Sets an item selection listener.
void setOnSearchClickedListener(View.OnClickListener listener)
Sets a click listener for the search affordance.
void setSearchAffordanceColor(int color)
Sets the color used to draw the search affordance.
void setSelectedPosition(int position)
Sets the selected item position.
void setTitle(String title)
Sets a title for the fragment.
[Expand]
Inherited Methods
From class android.app.Fragment
From class java.lang.Object
From interface android.content.ComponentCallbacks
From interface android.content.ComponentCallbacks2
From interface android.view.View.OnCreateContextMenuListener

Public Constructors

public VerticalGridFragment ()

Public Methods

public ObjectAdapter getAdapter ()

Returns the object adapter.

public Drawable getBadgeDrawable ()

Returns the badge drawable.

public VerticalGridPresenter getGridPresenter ()

Returns the grid presenter.

public OnItemClickedListener getOnItemClickedListener ()

Returns the item clicked listener.

public int getSearchAffordanceColor ()

Returns the color used to draw the search affordance.

public String getTitle ()

Returns the title for the fragment.

public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

Called to have the fragment instantiate its user interface view. This is optional, and non-graphical fragments can return null (which is the default implementation). This will be called between onCreate(Bundle) and onActivityCreated(Bundle).

If you return a View from here, you will later be called in onDestroyView() when the view is being released.

Parameters
inflater The LayoutInflater object that can be used to inflate any views in the fragment,
container If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view.
savedInstanceState If non-null, this fragment is being re-constructed from a previous saved state as given here.
Returns
  • Return the View for the fragment's UI, or null.

public void onDestroyView ()

Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment. The next time the fragment needs to be displayed, a new view will be created. This is called after onStop() and before onDestroy(). It is called regardless of whether onCreateView(LayoutInflater, ViewGroup, Bundle) returned a non-null view. Internally it is called after the view's state has been saved but before it has been removed from its parent.

public void onStart ()

Called when the Fragment is visible to the user. This is generally tied to Activity.onStart of the containing Activity's lifecycle.

public void onViewCreated (View view, Bundle savedInstanceState)

Called immediately after onCreateView(LayoutInflater, ViewGroup, Bundle) has returned, but before any saved state has been restored in to the view. This gives subclasses a chance to initialize themselves once they know their view hierarchy has been completely created. The fragment's view hierarchy is not however attached to its parent at this point.

Parameters
view The View returned by onCreateView(LayoutInflater, ViewGroup, Bundle).
savedInstanceState If non-null, this fragment is being re-constructed from a previous saved state as given here.

public void setAdapter (ObjectAdapter adapter)

Sets the object adapter for the fragment.

public void setBadgeDrawable (Drawable drawable)

Sets the badge drawable displayed in the title area.

public void setGridPresenter (VerticalGridPresenter gridPresenter)

Sets the grid presenter.

public void setOnItemClickedListener (OnItemClickedListener listener)

Sets an item clicked listener.

public void setOnItemSelectedListener (OnItemSelectedListener listener)

Sets an item selection listener.

public void setOnSearchClickedListener (View.OnClickListener listener)

Sets a click listener for the search affordance.

The presence of a listener will change the visibility of the search affordance in the title area. When set to non-null, the title area will contain a call to search action.

The listener's onClick method will be invoked when the user clicks on the search action.

Parameters
listener The listener to invoke when the search affordance is clicked, or null to hide the search affordance.

public void setSearchAffordanceColor (int color)

Sets the color used to draw the search affordance.

public void setSelectedPosition (int position)

Sets the selected item position.

public void setTitle (String title)

Sets a title for the fragment.