public static int GetIconId(string name, Context context) { if (icons.ContainsKey(name) == true) { return icons[name]; } int id = context.GetResources().GetIdentifier(name, "drawable", context.GetPackageName()); if (id == 0) { return 0; } icons.Add(name, id); return id; }
public LunarThread(LunarView view, ISurfaceHolder surfaceHolder, Context context, Handler handler) { // get handles to some important objects this.view = view; mSurfaceHolder = surfaceHolder; mHandler = handler; view.mContext = context; Resources res = context.Resources; // cache handles to our key sprites & other drawables mLanderImage = context.Resources.GetDrawable(R.Drawables.lander_plain); mFiringImage = context.Resources.GetDrawable(R.Drawables.lander_firing); mCrashedImage = context.GetResources().GetDrawable(R.Drawables.lander_crashed); // load background image as a Bitmap instead of a Drawable b/c // we don't need to transform it and it's faster to draw this way mBackgroundImage = BitmapFactory.DecodeResource(res, R.Drawables.earthrise); // Use the regular lander image as the model size for all sprites mLanderWidth = mLanderImage.IntrinsicWidth; mLanderHeight = mLanderImage.IntrinsicHeight; // Initialize paints for speedometer mLinePaint = new Paint(); mLinePaint.SetAntiAlias(true); mLinePaint.SetARGB(255, 0, 255, 0); mLinePaintBad = new Paint(); mLinePaintBad.SetAntiAlias(true); mLinePaintBad.SetARGB(255, 120, 180, 0); mScratchRect = new RectF(0, 0, 0, 0); mWinsInARow = 0; mDifficulty = DIFFICULTY_MEDIUM; // initial show-up of lander (not yet playing) mX = mLanderWidth; mY = mLanderHeight * 2; mFuel = PHYS_FUEL_INIT; mDX = 0; mDY = 0; mHeading = 0; mEngineFiring = true; }
private List<View> CreateSortContainers(Context context, Text2Speech tts) { var result = new List<View>(); var l = new HorizontalFlowLayout(context); l.SetBackgroundColor(context.GetResources().GetColor(R.Colors.light_blue)); var p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1); //var p = new RelativeLayout.MarginLayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); p.SetMargins(7, 7, 7, 0); l.SetLayoutParams(p); var d = new MoveDropHandler { Id = "1" }; d.OnMoveDropAccepted += sortObjects.ResultChecker.DropHandler; l.SetOnDragListener(d); result.Add(l); l = new HorizontalFlowLayout(context); l.SetBackgroundColor(context.GetResources().GetColor(R.Colors.light_blue)); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1); //p = new RelativeLayout.MarginLayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); p.SetMargins(7, 7, 7, 7); l.SetLayoutParams(p); d = new MoveDropHandler { Id = "2" }; d.OnMoveDropAccepted += sortObjects.ResultChecker.DropHandler; l.SetOnDragListener(d); result.Add(l); return result; }