specify a layout rather than a simple TextView for game list items,

step 1 toward better looking list.
This commit is contained in:
eehouse 2010-05-04 12:31:14 +00:00
parent e48caca6ac
commit 3c7d972d85
2 changed files with 21 additions and 2 deletions

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="4sp">
<TextView android:id="@+id/players"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</LinearLayout>

View file

@ -26,6 +26,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import android.database.DataSetObserver;
import java.io.FileInputStream;
import android.view.LayoutInflater;
import junit.framework.Assert;
@ -34,9 +35,11 @@ import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
public class GameListAdapter implements ListAdapter {
Context m_context;
LayoutInflater m_factory;
public GameListAdapter( Context context ) {
m_context = context;
m_factory = LayoutInflater.from( context );
}
public boolean areAllItemsEnabled() {
@ -53,7 +56,9 @@ public class GameListAdapter implements ListAdapter {
public Object getItem( int position )
{
TextView view = new TextView(m_context);
final View layout = m_factory.inflate( R.layout.game_list_item, null );
TextView view = (TextView)layout.findViewById( R.id.players );
String path = Utils.gamesList(m_context)[position];
byte[] stream = open( path );
if ( null != stream ) {
@ -65,7 +70,7 @@ public class GameListAdapter implements ListAdapter {
view.setText( summaryTxt );
}
return view;
return layout;
}
public long getItemId( int position ) {