ErrorFragment
– Android TV app hands on Tutorial 6

ErrorFragment-2015-07-07-131452

ErrorActivity & ErrorFragment

ErrorFragment is one of another layouts supported by Leanback library.

ErrorActivity

New -> Java Class -> Name: ErrorActivity
* We don’t use layout file for showing ErrorActivity.

Basically, it just attaches ErrorFragment.

ErrorFragment

New -> Java Class -> Name: ErrorFragment
* We don’t use layout file for showing ErrorActivity.

ErrorFragment class is a subclass of android.support.v17.leanback.app.ErrorFragment.

Modify AndroidManifest.xml to declare ErrorActivity,

 

Implement action to launch ErrorActivity

I will change the name of item of GridItemPresenter “Item 1″ -> “ErrorFragment”, and I will launch this ErrorActivity by clicking this “ErrorFragment” item.

Modify MainFragment, to launch ErrorActivity by intent.

 

 

Build and run

By clicking “ErrorFragment” item, ErrorFragment will show Error message with images.

ErrorFragment-2015-07-07-131452

 * AOSP project, SpinnerFragment is also implemented to show loading animation. But I introduced a minimum implementation/usage of ErrorFragment here.

Source code is on github.

 

Sponsored Links

One response

Leave a Reply

Your email address will not be published.