The containing layout should be a RelativeLayout and the "no results" view should be above the grid view.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/gridview_no_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:src="@drawable/background_no_results" />
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
... />
</RelativeLayout>
Code
Set the empty view
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
gridables = new ArrayList<CalendaredProgram>();
gridView = (GridView) view.findViewById(R.id.gridview);
ImageView noResultsView = (ImageView) view.findViewById(R.id.gridview_no_results);
gridView.setEmptyView(noResultsView);
this.setSearchButtonOnClickHandler();
}
Do request
private class SearchTask extends AsyncTask{ ... @Override protected void onPostExecute(Response response) { // Assign empty list if there are no results } @Override protected TaskResult doInBackground(Params... params) { // Do request } }
No hay comentarios:
Publicar un comentario