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.
This commit is contained in:
Andy2 2011-09-19 06:45:15 -07:00
parent ea3e015a8f
commit d7a04f87e6
3 changed files with 39 additions and 7 deletions

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView android:id="@+id/words"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:layout_marginLeft="30dip"
android:layout_marginRight="30dip"
/>
</LinearLayout>

View file

@ -1767,6 +1767,7 @@
<string name="button_lookup">Lookup word</string>
<string name="title_lookup">Tap to lookup</string>
<string name="button_done">Done</string>
</resources>

View file

@ -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<String> adapter =
new ArrayAdapter<String>( 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;