From 00eee811f4ff7625890981661565b8e966a04a52 Mon Sep 17 00:00:00 2001 From: Jimmy Shih Date: Thu, 12 Apr 2012 16:48:59 -0700 Subject: [PATCH] Add an empty view when the track list is empty. --- MyTracks/res/layout/track_list.xml | 31 ++++++++++++++++--- MyTracks/res/values/strings.xml | 5 +++ .../apps/mytracks/TrackListActivity.java | 11 +++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/MyTracks/res/layout/track_list.xml b/MyTracks/res/layout/track_list.xml index af2ae781c..2dd28fac4 100644 --- a/MyTracks/res/layout/track_list.xml +++ b/MyTracks/res/layout/track_list.xml @@ -14,12 +14,35 @@ 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. --> - + android:layout_width="fill_parent" > - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index aac2e360f..7c56bf74d 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -2221,6 +2221,11 @@ limitations under the License. the user that all tracks and markers will be permanently deleted from the phone."> All tracks and markers will be permanently deleted from the phone. + + You don\'t have any recorded tracks. Click on the record button to start a new recording. + diff --git a/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java b/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java index 5c78b8912..9b621dba8 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java @@ -54,6 +54,7 @@ import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; +import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -169,7 +170,17 @@ public class TrackListActivity extends FragmentActivity { metricUnits = sharedPreferences.getBoolean(getString(R.string.metric_units_key), true); recordingTrackId = PreferencesUtils.getRecordingTrackId(this); + ImageButton recordImageButton = (ImageButton) findViewById(R.id.track_list_record_button); + recordImageButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + updateMenuItems(true); + startRecording(); + } + }); + listView = (ListView) findViewById(R.id.track_list); + listView.setEmptyView(findViewById(R.id.track_list_empty)); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) {