From d058e3fd4b9afb62377165ca6be5ff8c5f646701 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Fri, 10 Jun 2011 20:02:14 -0700 Subject: [PATCH] use a layout instead of a raw text widgit. --- xwords4/android/XWords4/res/layout/dflt_name.xml | 9 +++++++++ .../XWords4/src/org/eehouse/android/xw4/GamesList.java | 3 ++- .../XWords4/src/org/eehouse/android/xw4/Utils.java | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 xwords4/android/XWords4/res/layout/dflt_name.xml diff --git a/xwords4/android/XWords4/res/layout/dflt_name.xml b/xwords4/android/XWords4/res/layout/dflt_name.xml new file mode 100644 index 000000000..e6e6b14ca --- /dev/null +++ b/xwords4/android/XWords4/res/layout/dflt_name.xml @@ -0,0 +1,9 @@ + + + diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index f32baf986..2761b1a84 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -161,7 +161,8 @@ public class GamesList extends XWListActivity }); break; case GET_NAME: - final EditText etext = new EditText( this ); + final EditText etext = + (EditText)Utils.inflate( this, R.layout.dflt_name ); etext.setText( CommonPrefs.getDefaultPlayerName( this, 0, true ) ); dialog = new AlertDialog.Builder( this ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index 024d30dba..ec785a166 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -32,6 +32,7 @@ import android.app.Activity; import android.app.Dialog; import android.widget.EditText; import android.widget.TextView; +import android.view.LayoutInflater; import android.view.View; import android.text.format.Time; import java.util.Formatter; @@ -104,6 +105,12 @@ public class Utils { Toast.makeText( context, text, Toast.LENGTH_SHORT).show(); } + public static View inflate( Context context, int layoutId ) + { + LayoutInflater factory = LayoutInflater.from( context ); + return factory.inflate( layoutId, null ); + } + public static void setChecked( Activity activity, int id, boolean value ) { CheckBox cbx = (CheckBox)activity.findViewById( id );