Add an empty view when the track list is empty.

This commit is contained in:
Jimmy Shih
2012-04-12 16:48:59 -07:00
parent e3f13dd633
commit 00eee811f4
3 changed files with 43 additions and 4 deletions
+27 -4
View File
@@ -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 See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:layout_width="fill_parent" >
android:orientation="vertical" >
<ListView <ListView
android:id="@+id/track_list" android:id="@+id/track_list"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_width="fill_parent" /> android:layout_width="fill_parent" />
</LinearLayout> <LinearLayout
android:gravity="center"
android:id="@+id/track_list_empty"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingBottom="8dp"
android:text="@string/track_list_empty_message"
style="@android:style/TextAppearance.DeviceDefault.Large" >
</TextView>
<ImageButton
android:contentDescription="@string/menu_record_track"
android:id="@+id/track_list_record_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="16dp"
android:src="@drawable/menu_record_track"
style="@android:style/Widget.DeviceDefault.ImageButton" />
</LinearLayout>
</FrameLayout>
+5
View File
@@ -2221,6 +2221,11 @@ limitations under the License.
the user that all tracks and markers will be permanently deleted from the phone."> 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. All tracks and markers will be permanently deleted from the phone.
</string> </string>
<string name="track_list_empty_message"
translation_description="When the track list is empty, the message informing the user to click
on the record button to start a new recording">
You don\'t have any recorded tracks. Click on the record button to start a new recording.
</string>
<string name="track_list_record_error" <string name="track_list_record_error"
translation_description="When starting a new track recording, the error message informing the translation_description="When starting a new track recording, the error message informing the
user not able to record and asking the user to try again."> user not able to record and asking the user to try again.">
@@ -54,6 +54,7 @@ import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageButton;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@@ -169,7 +170,17 @@ public class TrackListActivity extends FragmentActivity {
metricUnits = sharedPreferences.getBoolean(getString(R.string.metric_units_key), true); metricUnits = sharedPreferences.getBoolean(getString(R.string.metric_units_key), true);
recordingTrackId = PreferencesUtils.getRecordingTrackId(this); 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 = (ListView) findViewById(R.id.track_list);
listView.setEmptyView(findViewById(R.id.track_list_empty));
listView.setOnItemClickListener(new OnItemClickListener() { listView.setOnItemClickListener(new OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {