In this assignment, your requirment is to write an Android Scramble Game. The ga
ID: 3768040 • Letter: I
Question
In this assignment, your requirment is to write an Android Scramble Game. The game is played by forming the correct word from a scrambled word. You need to observe the following rules. 1. Scrambling a word should be done randomely; that is, it should not be hard-coded. You may use a random number generator to scramble a word. 2. It is possible that from a given scrambled word, there could be one or more answers.
|| Title Of Application ||
|| Answered Textfield ||
|| Scramble Word ||
|| New || || Play ||
Requirement +----------------------------+ 1. Please submit the Android Project in zip format.
Explanation / Answer
A) R.java
package android.alpha.scramble;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
}
B) main file
package android.alpha.scramble;
import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;
public class main extends Activity implements B4AActivity{
public static main mostCurrent;
static boolean afterFirstLayout;
static boolean isFirst = true;
private static boolean processGlobalsRun = false;
BALayout layout;
public static BA processBA;
BA activityBA;
ActivityWrapper _activity;
java.util.ArrayList<B4AMenuItem> menuItems;
public static final boolean fullScreen = false;
public static final boolean includeTitle = true;
public static WeakReference<Activity> previousOne;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFirst) {
processBA = new BA(this.getApplicationContext(), null, null, "android.alpha.scramble", "android.alpha.scramble.main");
processBA.loadHtSubs(this.getClass());
float deviceScale = getApplicationContext().getResources().getDisplayMetrics().density;
BALayout.setDeviceScale(deviceScale);
}
else if (previousOne != null) {
Activity p = previousOne.get();
if (p != null && p != this) {
BA.LogInfo("Killing previous instance (main).");
p.finish();
}
}
if (!includeTitle) {
this.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
}
if (fullScreen) {
getWindow().setFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,
android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
mostCurrent = this;
processBA.sharedProcessBA.activityBA = null;
layout = new BALayout(this);
setContentView(layout);
afterFirstLayout = false;
BA.handler.postDelayed(new WaitForLayout(), 5);
}
private static class WaitForLayout implements Runnable {
public void run() {
if (afterFirstLayout)
return;
if (mostCurrent == null)
return;
if (mostCurrent.layout.getWidth() == 0) {
BA.handler.postDelayed(this, 5);
return;
}
mostCurrent.layout.getLayoutParams().height = mostCurrent.layout.getHeight();
mostCurrent.layout.getLayoutParams().width = mostCurrent.layout.getWidth();
afterFirstLayout = true;
mostCurrent.afterFirstLayout();
}
}
private void afterFirstLayout() {
if (this != mostCurrent)
return;
activityBA = new BA(this, layout, processBA, "android.alpha.scramble", "android.alpha.scramble.main");
processBA.sharedProcessBA.activityBA = new java.lang.ref.WeakReference<BA>(activityBA);
anywheresoftware.b4a.objects.ViewWrapper.lastId = 0;
_activity = new ActivityWrapper(activityBA, "activity");
anywheresoftware.b4a.Msgbox.isDismissing = false;
if (BA.isShellModeRuntimeCheck(processBA)) {
if (isFirst)
processBA.raiseEvent2(null, true, "SHELL", false);
processBA.raiseEvent2(null, true, "CREATE", true, "android.alpha.scramble.main", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density);
_activity.reinitializeForShell(activityBA, "activity");
}
initializeProcessGlobals();
initializeGlobals();
BA.LogInfo("** Activity (main) Create, isFirst = " + isFirst + " **");
processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
isFirst = false;
if (this != mostCurrent)
return;
processBA.setActivityPaused(false);
BA.LogInfo("** Activity (main) Resume **");
processBA.raiseEvent(null, "activity_resume");
if (android.os.Build.VERSION.SDK_INT >= 11) {
try {
android.app.Activity.class.getMethod("invalidateOptionsMenu").invoke(this,(Object[]) null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void addMenuItem(B4AMenuItem item) {
if (menuItems == null)
menuItems = new java.util.ArrayList<B4AMenuItem>();
menuItems.add(item);
}
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
super.onCreateOptionsMenu(menu);
if (menuItems == null)
return false;
for (B4AMenuItem bmi : menuItems) {
android.view.MenuItem mi = menu.add(bmi.title);
if (bmi.drawable != null)
mi.setIcon(bmi.drawable);
if (android.os.Build.VERSION.SDK_INT >= 11) {
try {
if (bmi.addToBar) {
android.view.MenuItem.class.getMethod("setShowAsAction", int.class).invoke(mi, 1);
}
} catch (Exception e) {
e.printStackTrace();
}
}
mi.setOnMenuItemClickListener(new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
}
return true;
}
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (processBA.subExists("activity_windowfocuschanged"))
processBA.raiseEvent2(null, true, "activity_windowfocuschanged", false, hasFocus);
}
private class B4AMenuItemsClickListener implements android.view.MenuItem.OnMenuItemClickListener {
private final String eventName;
public B4AMenuItemsClickListener(String eventName) {
this.eventName = eventName;
}
public boolean onMenuItemClick(android.view.MenuItem item) {
processBA.raiseEvent(item.getTitle(), eventName + "_click");
return true;
}
}
public static Class<?> getObject() {
return main.class;
}
private Boolean>
private Boolean>
@Override
public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
if (onKeySubExist == null)
onKeySubExist = processBA.subExists("activity_keypress");
if (onKeySubExist) {
if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK &&
android.os.Build.VERSION.SDK_INT >= 18) {
HandleKeyDelayed hk = new HandleKeyDelayed();
hk.kc = keyCode;
BA.handler.post(hk);
return true;
}
else {
boolean res = new HandleKeyDelayed().runDirectly(keyCode);
if (res)
return true;
}
}
return super.onKeyDown(keyCode, event);
}
private class HandleKeyDelayed implements Runnable {
int kc;
public void run() {
runDirectly(kc);
}
public boolean runDirectly(int keyCode) {
Boolean res = (Boolean)processBA.raiseEvent2(_activity, false, "activity_keypress", false, keyCode);
if (res == null || res == true) {
return true;
}
else if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK) {
finish();
return true;
}
return false;
}
}
@Override
public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
if (onKeyUpSubExist == null)
onKeyUpSubExist = processBA.subExists("activity_keyup");
if (onKeyUpSubExist) {
Boolean res = (Boolean)processBA.raiseEvent2(_activity, false, "activity_keyup", false, keyCode);
if (res == null || res == true)
return true;
}
return super.onKeyUp(keyCode, event);
}
@Override
public void onNewIntent(android.content.Intent intent) {
this.setIntent(intent);
}
@Override
public void onPause() {
super.onPause();
if (_activity == null) //workaround for emulator bug (Issue 2423)
return;
anywheresoftware.b4a.Msgbox.dismiss(true);
BA.LogInfo("** Activity (main) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());
processBA.setActivityPaused(true);
mostCurrent = null;
if (!activityBA.activity.isFinishing())
previousOne = new WeakReference<Activity>(this);
anywheresoftware.b4a.Msgbox.isDismissing = false;
}
@Override
public void onDestroy() {
super.onDestroy();
previousOne = null;
}
@Override
public void onResume() {
super.onResume();
mostCurrent = this;
anywheresoftware.b4a.Msgbox.isDismissing = false;
if (activityBA != null) { //will be null during activity create (which waits for AfterLayout).
ResumeMessage rm = new ResumeMessage(mostCurrent);
BA.handler.post(rm);
}
}
private static class ResumeMessage implements Runnable {
private final WeakReference<Activity> activity;
public ResumeMessage(Activity activity) {
this.activity = new WeakReference<Activity>(activity);
}
public void run() {
if (mostCurrent == null || mostCurrent != activity.get())
return;
processBA.setActivityPaused(false);
BA.LogInfo("** Activity (main) Resume **");
processBA.raiseEvent(mostCurrent._activity, "activity_resume", (Object[])null);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
android.content.Intent data) {
processBA.onActivityResult(requestCode, resultCode, data);
}
private static void initializeGlobals() {
processBA.raiseEvent2(null, true, "globals", false, (Object[])null);
}
public anywheresoftware.b4a.keywords.Common __c = null;
public static anywheresoftware.b4a.objects.Timer _timer1 = null;
public static anywheresoftware.b4a.objects.Timer _timer2 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview1 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview2 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview3 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview4 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview5 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview6 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview7 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview8 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview9 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview10 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview11 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview12 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview13 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview14 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview15 = null;
public static String[] _ltr = null;
public static int _r = 0;
public static String _let = "";
public static int _flip = 0;
public static String _l1 = "";
public static String _l2 = "";
public static String _l3 = "";
public static String _l4 = "";
public static String _l5 = "";
public static String _p1 = "";
public static String _p2 = "";
public static String _p3 = "";
public static String _p4 = "";
public static String _p5 = "";
public static String _word = "";
public anywheresoftware.b4a.objects.LabelWrapper _label1 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label2 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label3 = null;
public static int _z = 0;
public static String[] _wrd = null;
public static int _seconds = 0;
public anywheresoftware.b4a.objects.SpinnerWrapper _spinner1 = null;
public static String _speed = "";
public static boolean isAnyActivityVisible() {
boolean vis = false;
vis = vis | (main.mostCurrent != null);
return vis;}
public static String _activity_create(boolean _firsttime) throws Exception{
mostCurrent._activity.LoadLayout("scramble.bal",mostCurrent.activityBA);
mostCurrent._imageview1.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"a.png").getObject()));
mostCurrent._imageview2.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"b.png").getObject()));
//BA.debugLineNum = 78;BA.debugLine="ImageView3.Bitmap = LoadBitmap(File.DirAssets, "c.png")";
mostCurrent._imageview3.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"c.png").getObject()));
//BA.debugLineNum = 79;BA.debugLine="ImageView4.Bitmap = LoadBitmap(File.DirAssets, "d.png")";
mostCurrent._imageview4.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"d.png").getObject()));
//BA.debugLineNum = 80;BA.debugLine="ImageView5.Bitmap = LoadBitmap(File.DirAssets, "e.png")";
mostCurrent._imageview5.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"e.png").getObject()));
//BA.debugLineNum = 81;BA.debugLine="ImageView6.Bitmap = LoadBitmap(File.DirAssets, "f.png")";
mostCurrent._imageview6.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"f.png").getObject()));
//BA.debugLineNum = 82;BA.debugLine="ImageView7.Bitmap = LoadBitmap(File.DirAssets, "g.png")";
mostCurrent._imageview7.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"g.png").getObject()));
//BA.debugLineNum = 83;BA.debugLine="ImageView8.Bitmap = LoadBitmap(File.DirAssets, "h.png")";
mostCurrent._imageview8.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"h.png").getObject()));
mostCurrent._imageview9.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"i.png").getObject()));
mostCurrent._imageview10.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"j.png").getObject()));
mostCurrent._imageview11.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"k.png").getObject()));
mostCurrent._imageview12.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"l.png").getObject()));
mostCurrent._imageview13.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"m.png").getObject()));
mostCurrent._imageview14.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"n.png").getObject()));
mostCurrent._imageview15.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"o.png").getObject()));
mostCurrent._spinner1.AddAll(anywheresoftware.b4a.keywords.Common.ArrayToList(new String[]{"Slow","Med","Fast"}));
mostCurrent._spinner1.setSelectedIndex((int) (0));
mostCurrent._speed = "Slow";
_restart();
return "";
}
public static String _button1_click() throws Exception{
mostCurrent._activity.Finish();
return "";
}
public static String _button2_click() throws Exception{
_restart();
return "";
}
public static String _calcx() throws Exception{
if ((mostCurrent._ltr[_z]).equals(mostCurrent._l1)) {
mostCurrent._p1 = mostCurrent._l1;
};
if ((mostCurrent._ltr[_z]).equals(mostCurrent._l2)) {
mostCurrent._p2 = mostCurrent._l2;
};
if ((mostCurrent._ltr[_z]).equals(mostCurrent._l3)) {
mostCurrent._p3 = mostCurrent._l3;
};
if ((mostCurrent._ltr[_z]).equals(mostCurrent._l4)) {
mostCurrent._p4 = mostCurrent._l4;
};
if ((mostCurrent._ltr[_z]).equals(mostCurrent._l5)) {
mostCurrent._p5 = mostCurrent._l5;
};
mostCurrent._label2.setText((Object)("TYPED-"+mostCurrent._p1+mostCurrent._p2+mostCurrent._p3+mostCurrent._p4+mostCurrent._p5));
if ((mostCurrent._p1+mostCurrent._p2+mostCurrent._p3+mostCurrent._p4+mostCurrent._p5).equals(mostCurrent._word)) {
anywheresoftware.b4a.keywords.Common.Msgbox("You won!","",mostCurrent.activityBA);
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.False);
};
return "";
}
public static void initializeProcessGlobals() {
if (main.processGlobalsRun == false) {
main.processGlobalsRun = true;
try {
main._process_globals();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}public static String _globals() throws Exception{
mostCurrent._imageview1 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview2 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview3 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview4 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview5 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview6 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview7 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview8 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview9 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview10 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview11 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview12 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview13 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._imageview14 = new anywheresoftware.b4a.objects.ImageViewWrapper();;
mostCurrent._imageview15 = new anywheresoftware.b4a.objects.ImageViewWrapper();
mostCurrent._ltr = new String[(int) (15)];
java.util.Arrays.fill(mostCurrent._ltr,"");
_r = 0;
mostCurrent._let = "";
_flip = 0;
mostCurrent._l1 = "";
mostCurrent._l2 = "";
mostCurrent._l3 = "";
mostCurrent._l4 = "";
mostCurrent._l5 = "";
mostCurrent._p1 = "";
mostCurrent._p2 = "";
mostCurrent._p3 = "";
mostCurrent._p4 = "";
mostCurrent._p5 = "";
mostCurrent._word = "";
mostCurrent._label1 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._label2 = new anywheresoftware.b4a.objects.LabelWrapper();
//BA.debugLineNum = 60;BA.debugLine="Dim label3 As Label";
mostCurrent._label3 = new anywheresoftware.b4a.objects.LabelWrapper();
//BA.debugLineNum = 62;BA.debugLine="Dim z As Int";
_z = 0;
mostCurrent._wrd = new String[(int) (20)];
java.util.Arrays.fill(mostCurrent._wrd,"");
_seconds = 0;
mostCurrent._spinner1 = new anywheresoftware.b4a.objects.SpinnerWrapper();
mostCurrent._speed = "";
return "";
}
public static String _imageview1_click() throws Exception{
_z = (int) (0);
_calcx();
return "";
}
public static String _imageview10_click() throws Exception{
_z = (int) (9);
_calcx();
return "";
}
public static String _imageview11_click() throws Exception{
_z = (int) (10);
_calcx();
return "";
}
public static String _imageview12_click() throws Exception{
_z = (int) (11);
_calcx();
return "";
}
public static String _imageview13_click() throws Exception{
_z = (int) (12);
_calcx();
return "";
}
public static String _imageview14_click() throws Exception{
_z = (int) (13);
_calcx();
return "";
}
public static String _imageview15_click() throws Exception{
_z = (int) (14);
_calcx();
return "";
}
public static String _imageview2_click() throws Exception{
_z = (int) (1);
_calcx();
return "";
}
public static String _imageview3_click() throws Exception{
_z = (int) (2);
_calcx();
return "";
}
public static String _imageview4_click() throws Exception{
_z = (int) (3);
_calcx();
return "";
}
public static String _imageview5_click() throws Exception{
_z = (int) (4);
_calcx();
return "";
}
public static String _imageview6_click() throws Exception{;
_z = (int) (5);
_calcx();
return "";
}
public static String _imageview7_click() throws Exception{
_z = (int) (6);
_calcx();
return "";
}
public static String _imageview8_click() throws Exception{
_z = (int) (7);
_calcx();
return "";
}
public static String _imageview9_click() throws Exception{
_z = (int) (8);
_calcx();
return "";
}
public static String _process_globals() throws Exception{
_timer1 = new anywheresoftware.b4a.objects.Timer();
_timer2 = new anywheresoftware.b4a.objects.Timer();
return "";
}
public static String _rand() throws Exception{
_r = anywheresoftware.b4a.keywords.Common.Rnd((int) (1),(int) (25));
if (_r==1) {
mostCurrent._let = "a";
};
//BA.debugLineNum = 259;BA.debugLine="If r=2 Then";
if (_r==2) {
mostCurrent._let = "b";
};
if (_r==3) {
mostCurrent._let = "c";
};
if (_r==4) {
mostCurrent._let = "d";
};
if (_r==5) {
mostCurrent._let = "e";
};
if (_r==6) {
mostCurrent._let = "f";
};
if (_r==7) {
mostCurrent._let = "g";
};
//BA.debugLineNum = 283;BA.debugLine="If r=8 Then";
if (_r==8) {
mostCurrent._let = "h";
};
if (_r==9) {
mostCurrent._let = "i";
};
if (_r==10) {
mostCurrent._let = "j";
};
if (_r==11) {
mostCurrent._let = "k";
};
if (_r==12) {
mostCurrent._let = "l";
};
//BA.debugLineNum = 303;BA.debugLine="If r=13 Then";
if (_r==13) {
mostCurrent._let = "m";
};
if (_r==14) {
mostCurrent._let = "n";
};
if (_r==15) {
mostCurrent._let = "o";
};
if (_r==16) {
mostCurrent._let = "p";
};
if (_r==17) {
mostCurrent._let = "q";
};
if (_r==18) {
mostCurrent._let = "r";
};
if (_r==19) {
mostCurrent._let = "s";
};
if (_r==20) {
mostCurrent._let = "t";
};
if (_r==21) {
mostCurrent._let = "u";
};
if (_r==22) {
mostCurrent._let = "v";
};
if (_r==23) {
mostCurrent._let = "w";
};
if (_r==24) {
mostCurrent._let = "x";
};
if (_r==25) {
mostCurrent._let = "y";
};
if (_r==26) {
mostCurrent._let = "z";
};
return "";
}
public static String _restart() throws Exception{
_seconds = (int) (0);
mostCurrent._label3.setText((Object)("TIME -"+BA.NumberToString(_seconds)));
if ((mostCurrent._speed).equals("Slow")) {
_timer1.Initialize(processBA,"Timer1",(long) (2125));
};
if ((mostCurrent._speed).equals("Med")) {
_timer1.Initialize(processBA,"Timer1",(long) (1500));
};
if ((mostCurrent._speed).equals("Fast")) {
_timer1.Initialize(processBA,"Timer1",(long) (1000));
};
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.False);
mostCurrent._wrd[(int) (0)] = "hello";
mostCurrent._wrd[(int) (1)] = "tried";
mostCurrent._wrd[(int) (2)] = "looks";
mostCurrent._wrd[(int) (3)] = "fried";
mostCurrent._wrd[(int) (4)] = "hosts";
mostCurrent._wrd[(int) (5)] = "jerks";
mostCurrent._wrd[(int) (6)] = "spoon";
mostCurrent._wrd[(int) (7)] = "dread";
mostCurrent._wrd[(int) (8)] = "reads";
mostCurrent._wrd[(int) (9)] = "timed";
mostCurrent._wrd[(int) (10)] = "bring";
mostCurrent._wrd[(int) (11)] = "sling";
mostCurrent._wrd[(int) (12)] = "wrong";
mostCurrent._wrd[(int) (13)] = "right";
mostCurrent._wrd[(int) (14)] = "hello";
mostCurrent._wrd[(int) (15)] = "trend";
mostCurrent._wrd[(int) (16)] = "traps";
mostCurrent._wrd[(int) (17)] = "paint";
mostCurrent._wrd[(int) (18)] = "untie";
mostCurrent._wrd[(int) (19)] = "trust";
_z = 0;
_z = anywheresoftware.b4a.keywords.Common.Rnd((int) (0),(int) (20));
mostCurrent._word = mostCurrent._wrd[_z];
mostCurrent._p1 = "_";
mostCurrent._p2 = "_";
mostCurrent._p3 = "_";
mostCurrent._p4 = "_";
mostCurrent._p5 = "_";
mostCurrent._label2.setText((Object)("TYPED-"+mostCurrent._p1+mostCurrent._p2+mostCurrent._p3+mostCurrent._p4+mostCurrent._p5));
mostCurrent._l1 = mostCurrent._word.substring((int) (0),(int) (1));
mostCurrent._l2 = mostCurrent._word.substring((int) (1),(int) (2));
mostCurrent._l3 = mostCurrent._word.substring((int) (2),(int) (3));
mostCurrent._l4 = mostCurrent._word.substring((int) (3),(int) (4));
mostCurrent._l5 = mostCurrent._word.substring((int) (4),(int) (5));
mostCurrent._label1.setText((Object)("WORD-"+mostCurrent._word));
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.True);
return "";
}
public static String _spinner1_itemclick(int _position,Object _value) throws Exception{
mostCurrent._speed = BA.ObjectToString(_value);
return "";
}
public static String _timer1_tick() throws Exception{
int _x = 0;
_seconds = (int) (_seconds+1);
_x = 0;
_flip = (int) (_flip+1);
if (_flip>2) {
_flip = (int) (1);
};
{
final int step286 = 1;
final int limit286 = (int) (15);
for (_x = (int) (1); (step286 > 0 && _x <= limit286) || (step286 < 0 && _x >= limit286); _x = ((int)(0 + _x + step286))) {
if (_x==1) {
_rand();
mostCurrent._ltr[(int) (0)] = mostCurrent._let;
mostCurrent._imageview1.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
if (_x==2) {
_rand();
mostCurrent._ltr[(int) (1)] = mostCurrent._let;
mostCurrent._imageview2.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
if (_x==3) {
_rand();
//BA.debugLineNum = 389;BA.debugLine="ltr(2)=let";
mostCurrent._ltr[(int) (2)] = mostCurrent._let;
//BA.debugLineNum = 390;BA.debugLine="ImageView3.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview3.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 393;BA.debugLine="If x=4 Then";
if (_x==4) {
//BA.debugLineNum = 394;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 395;BA.debugLine="ltr(3)=let";
mostCurrent._ltr[(int) (3)] = mostCurrent._let;
//BA.debugLineNum = 396;BA.debugLine="ImageView4.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview4.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 399;BA.debugLine="If x=5 Then";
if (_x==5) {
//BA.debugLineNum = 400;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 401;BA.debugLine="ltr(4)=let";
mostCurrent._ltr[(int) (4)] = mostCurrent._let;
//BA.debugLineNum = 402;BA.debugLine="ImageView5.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview5.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 405;BA.debugLine="If x=6 Then";
if (_x==6) {
//BA.debugLineNum = 406;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 407;BA.debugLine="ltr(5)=let";
mostCurrent._ltr[(int) (5)] = mostCurrent._let;
//BA.debugLineNum = 408;BA.debugLine="ImageView6.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview6.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 411;BA.debugLine="If x=7 Then";
if (_x==7) {
//BA.debugLineNum = 412;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 413;BA.debugLine="ltr(6)=let";
mostCurrent._ltr[(int) (6)] = mostCurrent._let;
//BA.debugLineNum = 414;BA.debugLine="ImageView7.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview7.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 417;BA.debugLine="If x=8 Then";
if (_x==8) {
//BA.debugLineNum = 418;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 419;BA.debugLine="ltr(7)=let";
mostCurrent._ltr[(int) (7)] = mostCurrent._let;
//BA.debugLineNum = 420;BA.debugLine="ImageView8.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview8.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 423;BA.debugLine="If x=9 Then";
if (_x==9) {
//BA.debugLineNum = 424;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 425;BA.debugLine="ltr(8)=let";
mostCurrent._ltr[(int) (8)] = mostCurrent._let;
//BA.debugLineNum = 426;BA.debugLine="ImageView9.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview9.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 429;BA.debugLine="If x=10 Then";
if (_x==10) {
//BA.debugLineNum = 430;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 431;BA.debugLine="ltr(9)=let";
mostCurrent._ltr[(int) (9)] = mostCurrent._let;
//BA.debugLineNum = 432;BA.debugLine="ImageView10.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview10.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 435;BA.debugLine="If x=11 Then";
if (_x==11) {
//BA.debugLineNum = 436;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 437;BA.debugLine="ltr(10)=let";
mostCurrent._ltr[(int) (10)] = mostCurrent._let;
//BA.debugLineNum = 438;BA.debugLine="ImageView11.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview11.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 441;BA.debugLine="If x=12 Then";
if (_x==12) {
//BA.debugLineNum = 442;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 443;BA.debugLine="ltr(11)=let";
mostCurrent._ltr[(int) (11)] = mostCurrent._let;
//BA.debugLineNum = 444;BA.debugLine="ImageView12.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview12.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 447;BA.debugLine="If x=13 Then";
if (_x==13) {
//BA.debugLineNum = 448;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 449;BA.debugLine="ltr(12)=let";
mostCurrent._ltr[(int) (12)] = mostCurrent._let;
//BA.debugLineNum = 450;BA.debugLine="ImageView13.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview13.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 453;BA.debugLine="If x=14 Then";
if (_x==14) {
//BA.debugLineNum = 454;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 455;BA.debugLine="ltr(13)=let";
mostCurrent._ltr[(int) (13)] = mostCurrent._let;
//BA.debugLineNum = 456;BA.debugLine="ImageView14.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview14.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
//BA.debugLineNum = 459;BA.debugLine="If x=15 Then";
if (_x==15) {
//BA.debugLineNum = 460;BA.debugLine="rand";
_rand();
//BA.debugLineNum = 461;BA.debugLine="ltr(14)=let";
mostCurrent._ltr[(int) (14)] = mostCurrent._let;
//BA.debugLineNum = 462;BA.debugLine="ImageView15.Bitmap = LoadBitmap(File.DirAssets, let & ".png")";
mostCurrent._imageview15.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),mostCurrent._let+".png").getObject()));
};
}
};
//BA.debugLineNum = 465;BA.debugLine="label3.text="TIME -"&seconds";
mostCurrent._label3.setText((Object)("TIME -"+BA.NumberToString(_seconds)));
//BA.debugLineNum = 467;BA.debugLine="If seconds=30 Then";
if (_seconds==30) {
//BA.debugLineNum = 468;BA.debugLine="Timer1.Enabled = False";
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.False);
//BA.debugLineNum = 469;BA.debugLine="Msgbox("You lost!","")";
anywheresoftware.b4a.keywords.Common.Msgbox("You lost!","",mostCurrent.activityBA);
};
//BA.debugLineNum = 472;BA.debugLine="End Sub";
return "";
}
}
C) LS_scramble class
package android.alpha.scramble.designerscripts;
import anywheresoftware.b4a.objects.TextViewWrapper;
import anywheresoftware.b4a.objects.ImageViewWrapper;
import anywheresoftware.b4a.BA;
public class LS_scramble{
public static void LS_general(java.util.LinkedHashMap<String, anywheresoftware.b4a.keywords.LayoutBuilder.ViewWrapperAndAnchor> views, int width, int height, float scale) {
anywheresoftware.b4a.keywords.LayoutBuilder.setScaleRate(0.3);
//BA.debugLineNum = 2;BA.debugLine="AutoScaleAll"[scramble/General script]
anywheresoftware.b4a.keywords.LayoutBuilder.scaleAll(views);
}
}
D) Manifest File
<?xml version="1.0" encoding="utf-8" ?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.alpha.scramble" android:versionCode="1" android:versionName="" android:installLocation="internalOnly">
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" />
- <application android:icon="@drawable/icon" android:label="word scramble">
- <activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name=".main" android:label="word scramble" android:screenOrientation="unspecified">
- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.