From d7a04f87e6376f142081e572676b6233c58a1898 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 19 Sep 2011 06:45:15 -0700 Subject: [PATCH] add custom view for wordlist dialog so it doesn't get dismissed the first time you pick a word -- now all can be looked up if desired. --- .../XWords4/res/layout/wordlist_view.xml | 16 ++++++++++ .../android/XWords4/res/values/strings.xml | 1 + .../eehouse/android/xw4/BoardActivity.java | 29 ++++++++++++++----- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 xwords4/android/XWords4/res/layout/wordlist_view.xml diff --git a/xwords4/android/XWords4/res/layout/wordlist_view.xml b/xwords4/android/XWords4/res/layout/wordlist_view.xml new file mode 100644 index 000000000..2fc096058 --- /dev/null +++ b/xwords4/android/XWords4/res/layout/wordlist_view.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index fcf980420..b05c2b52c 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -1767,6 +1767,7 @@ Lookup word Tap to lookup + Done diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index 4092e051b..0a6df0c7c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -40,10 +40,14 @@ import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.EditText; +import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import junit.framework.Assert; @@ -316,15 +320,26 @@ public class BoardActivity extends XWActivity } break; case DLG_WORDPICK: + LinearLayout layout = + (LinearLayout)Utils.inflate( this, R.layout.wordlist_view ); + ListView list = (ListView)layout.findViewById( R.id.words ); + ArrayAdapter adapter = + new ArrayAdapter( this, + android.R.layout.simple_list_item_1, + m_words ) ; + list.setAdapter( adapter ); + OnItemClickListener oicl = new OnItemClickListener() { + public void onItemClick(AdapterView parent, + View view, + int position, long id ) { + lookupWord( m_words[position] ); + } + }; + list.setOnItemClickListener( oicl ); dialog = new AlertDialog.Builder( this ) .setTitle( R.string.title_lookup ) - .setItems( m_words, new DialogInterface.OnClickListener() { - public void onClick( DialogInterface dialog, - int item ) { - lookupWord( m_words[item] ); - } - } ) - .setNegativeButton( R.string.button_cancel, null ) + .setView( layout ) + .setNegativeButton( R.string.button_done, null ) .create(); Utils.setRemoveOnDismiss( this, dialog, id ); break;