Added empty list view in ForecastFragment

This commit is contained in:
Dan Galpin
2015-05-24 14:07:17 -07:00
parent 520559f11c
commit cb96ffb438
3 changed files with 17 additions and 0 deletions

View File

@@ -139,6 +139,8 @@ public class ForecastFragment extends Fragment implements LoaderManager.LoaderCa
// Get a reference to the ListView, and attach this adapter to it. // Get a reference to the ListView, and attach this adapter to it.
mListView = (ListView) rootView.findViewById(R.id.listview_forecast); mListView = (ListView) rootView.findViewById(R.id.listview_forecast);
View emptyView = rootView.findViewById(R.id.listview_forecast_empty);
mListView.setEmptyView(emptyView);
mListView.setAdapter(mForecastAdapter); mListView.setAdapter(mForecastAdapter);
// We'll call our MainActivity // We'll call our MainActivity
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

View File

@@ -24,4 +24,16 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:divider="@null" /> android:divider="@null" />
<!-- empty list -->
<TextView
android:id="@+id/listview_forecast_empty"
android:text="@string/empty_forecast_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
/>
</FrameLayout> </FrameLayout>

View File

@@ -109,4 +109,7 @@
<!-- Strings related to Notification preference --> <!-- Strings related to Notification preference -->
<string name="pref_last_notification">last_notification</string> <string name="pref_last_notification">last_notification</string>
<!-- Empty Weather Database -->
<string name="empty_forecast_list">No Weather Information Available</string>
</resources> </resources>