add an empty view along side list view; all setEmptyView to install it

to be shown when list is empty.
This commit is contained in:
Andy2 2010-12-16 18:47:25 -08:00
parent 740060f531
commit 693909ec67
3 changed files with 27 additions and 7 deletions

View file

@ -7,11 +7,26 @@
android:paddingLeft="8dp"
android:paddingRight="8dp">
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
<!-- FrameLayout required since Activity will pick between the two
view using the latter only if the list is empty. -->
<FrameLayout android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"
/>
<TextView android:id="@+id/empty_games_list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:text="@string/empty_games_list"
/>
</FrameLayout>
<Button android:id="@+id/new_game"
android:layout_width="fill_parent"

View file

@ -502,4 +502,8 @@
<string name="no_empty_rooms">This game cannot connect without a
room name.</string>
<string name="empty_games_list">Use one of the buttons below to
create a game. Then tap the game to play or long-tap it for
other options.</string>
</resources>

View file

@ -179,14 +179,15 @@ public class GamesList extends XWListActivity
m_handler = new Handler();
setContentView(R.layout.game_list);
ListView listView = getListView();
listView.setEmptyView( findViewById( R.id.empty_games_list ) );
registerForContextMenu( listView );
boolean isUpgrade = FirstRunDialog.show( this, false );
PreferenceManager.setDefaultValues( this, R.xml.xwprefs, isUpgrade );
// setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
registerForContextMenu( getListView() );
Button newGameB = (Button)findViewById(R.id.new_game);
newGameB.setOnClickListener( new View.OnClickListener() {
@Override