A custom view that displays an error image, a title, and a subtitle given an HTTP status code. It can be used for various other purposes like displaying other kinds of errors, or just messages with images.
#Usage ###Add as a dependency
compile 'com.github.xiprox.errorview:library:2.+'
###Set the error by HTTP Status Code
You just need to pass your HTTP status code using setError(int)
and ErrorView will show the associated error description for you.
###Set the error manually
In order to set the title or the subtitle manually, you can make use of the setTitle(String)
, setTitle(int)
, setSubtitle(String)
, and setSubtitle(int)
methods.
###Configs Configs are like packages that hold the ErrorView state. You can use configs to define a very common error and reuse it all around your app.
mErrorView.setConfig(Config);
mErrorView.getConfig();
####Defining a Config
ErrorView.Config.create()
.image(int)
.image(Drawable)
.image(Bitmap)
.title(String)
.titleColor(int)
.subtitle(String)
.subtitleColor(int)
.retryVisible(boolean)
.retryText(String)
.retryTextColor(int)
.build();
###Catch Retry Events
To catch retry events, you can make use of the setOnRetryListener(RetryListener)
method.
###More Methods Check out the source code for other methods and their explanations.
###XML Attributes
<tr.xip.errorview.ErrorView xmlns:errorview="http://schemas.android.com/apk/res-auto"
android:id="@+id/error_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
errorview:ev_title="@string/..."
errorview:ev_titleColor="@color/..."
errorview:ev_subtitle="@string/..."
errorview:ev_subtitleColor="@color/..."
errorview:ev_errorImage="@drawable/..."
errorview:ev_showTitle="boolean"
errorview:ev_showSubtitle="boolean"
errorview:ev_showRetryButton="boolean"
errorview:ev_retryButtonText="@string/..."
errorview:ev_retryButtonBackground="@drawable/..."
errorview:ev_retryButtonTextColor="@color/..." />
#Apps using ErrorView Check out this wiki page for the list of apps using ErrorView. If you are using ErrorView in your app, please take a moment to add your app to the list. I really appreciate it.
#License
Copyright (C) 2015 Ihsan Isik
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.