add string array to spinner manually so it can be translated -- sucks

to have to change code for this, but...  The dropdown views look
crappy though I'm using identical code to what's in DictLangCache
building similar arrays that look fine.  Needs work.
This commit is contained in:
Eric House 2014-04-10 06:44:33 -07:00
parent f3b5cbb794
commit 5c5a353d12
3 changed files with 20 additions and 2 deletions

View file

@ -235,7 +235,6 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:entries="@array/robot_levels"
/>
<Spinner android:id="@+id/phonies_spinner"
@ -243,7 +242,6 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:entries="@array/phony_names"
/>
<CheckBox android:id="@+id/pick_faceup"

View file

@ -426,8 +426,10 @@ public class GameConfig extends XWActivity
m_playerLayout = (LinearLayout)findViewById( R.id.player_list );
m_langSpinner = (Spinner)findViewById( R.id.lang_spinner );
m_phoniesSpinner = (Spinner)findViewById( R.id.phonies_spinner );
Utils.addSpinnerArray( m_phoniesSpinner, R.array.phony_names );
m_boardsizeSpinner = (Spinner)findViewById( R.id.boardsize_spinner );
m_smartnessSpinner = (Spinner)findViewById( R.id.smart_robot );
Utils.addSpinnerArray( m_smartnessSpinner, R.array.robot_levels );
} // onCreate
@Override

View file

@ -41,8 +41,10 @@ import android.telephony.TelephonyManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
@ -50,6 +52,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import junit.framework.Assert;
import org.eehouse.android.xw4.jni.*;
@ -469,6 +472,21 @@ public class Utils {
return result;
}
public static void addSpinnerArray( Spinner spinner, int arrayID )
{
Context context = spinner.getContext();
String[] array = context.getResources().getStringArray( arrayID );
array = LocUtils.xlateStrings( context, array );
int displayID = android.R.layout.simple_spinner_item;
// displayID = android.R.layout.simple_list_item_1;
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( context, displayID/*, array */ );
for ( String item : array ) {
adapter.add( item );
}
spinner.setAdapter( adapter );
}
private static void setFirstBootStatics( Context context )
{
int thisVersion = getAppVersion( context );