mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
specify a layout rather than a simple TextView for game list items,
step 1 toward better looking list.
This commit is contained in:
parent
e48caca6ac
commit
3c7d972d85
2 changed files with 21 additions and 2 deletions
14
xwords4/android/XWords4/res/layout/game_list_item.xml
Normal file
14
xwords4/android/XWords4/res/layout/game_list_item.xml
Normal 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>
|
|
@ -26,6 +26,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.database.DataSetObserver;
|
import android.database.DataSetObserver;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,9 +35,11 @@ import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
||||||
|
|
||||||
public class GameListAdapter implements ListAdapter {
|
public class GameListAdapter implements ListAdapter {
|
||||||
Context m_context;
|
Context m_context;
|
||||||
|
LayoutInflater m_factory;
|
||||||
|
|
||||||
public GameListAdapter( Context context ) {
|
public GameListAdapter( Context context ) {
|
||||||
m_context = context;
|
m_context = context;
|
||||||
|
m_factory = LayoutInflater.from( context );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areAllItemsEnabled() {
|
public boolean areAllItemsEnabled() {
|
||||||
|
@ -53,7 +56,9 @@ public class GameListAdapter implements ListAdapter {
|
||||||
|
|
||||||
public Object getItem( int position )
|
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];
|
String path = Utils.gamesList(m_context)[position];
|
||||||
byte[] stream = open( path );
|
byte[] stream = open( path );
|
||||||
if ( null != stream ) {
|
if ( null != stream ) {
|
||||||
|
@ -65,7 +70,7 @@ public class GameListAdapter implements ListAdapter {
|
||||||
|
|
||||||
view.setText( summaryTxt );
|
view.setText( summaryTxt );
|
||||||
}
|
}
|
||||||
return view;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getItemId( int position ) {
|
public long getItemId( int position ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue