List of usage examples for android.widget FrameLayout addView
public void addView(View child)
Adds a child view.
From source file:com.abhi.barcode.frag.libv2.BarcodeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout frameLayout = new FrameLayout(getActivity()); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);// ww w . j a va2 s. c o m frameLayout.setLayoutParams(layoutParams); surfaceView = new SurfaceView(getActivity()); surfaceView.setLayoutParams(layoutParams); viewfinderView = new ViewfinderView(getActivity()); viewfinderView.setLayoutParams(layoutParams); frameLayout.addView(surfaceView); frameLayout.addView(viewfinderView); View v = frameLayout; inactivityTimer = new InactivityTimer(this.getActivity()); ambientLightManager = new AmbientLightManager(this.getActivity()); return v; }
From source file:net.sylvek.sharemyposition.ShareMyPosition.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { default:/*from w ww .j a v a2 s . c om*/ return super.onCreateDialog(id); case MAP_DLG: final View sharedMapView = LayoutInflater.from(this).inflate(R.layout.sharedmap, null); final FrameLayout map = (FrameLayout) sharedMapView.findViewById(R.id.sharedmap); map.addView(this.sharedMap); final CheckBox latlonAddress = (CheckBox) sharedMapView.findViewById(R.id.add_lat_lon_location); final CheckBox geocodeAddress = (CheckBox) sharedMapView.findViewById(R.id.add_address_location); final RadioButton nourl = (RadioButton) sharedMapView.findViewById(R.id.add_no_url_location); final RadioButton url = (RadioButton) sharedMapView.findViewById(R.id.add_url_location); final RadioButton gmap = (RadioButton) sharedMapView.findViewById(R.id.add_native_location); final EditText body = (EditText) sharedMapView.findViewById(R.id.body); final ToggleButton track = (ToggleButton) sharedMapView.findViewById(R.id.add_track_location); latlonAddress.setChecked(pref.getBoolean(PREF_LAT_LON_CHECKED, true)); geocodeAddress.setChecked(pref.getBoolean(PREF_ADDRESS_CHECKED, true)); final boolean isUrl = pref.getBoolean(PREF_URL_CHECKED, true); final boolean isGmap = pref.getBoolean(PREF_GMAP_CHECKED, false); url.setChecked(isUrl); gmap.setChecked(isGmap); nourl.setChecked(!isUrl && !isGmap); body.setText(pref.getString(PREF_BODY_DEFAULT, getString(R.string.body))); track.setChecked(pref.getBoolean(PREF_TRACK_CHECKED, false)); if (track.isChecked()) { latlonAddress.setEnabled(false); latlonAddress.setChecked(false); geocodeAddress.setEnabled(false); geocodeAddress.setChecked(false); url.setEnabled(false); url.setChecked(true); gmap.setEnabled(false); gmap.setChecked(false); nourl.setEnabled(false); nourl.setChecked(false); } track.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { latlonAddress.setEnabled(!isChecked); latlonAddress.setChecked(!isChecked); geocodeAddress.setEnabled(!isChecked); geocodeAddress.setChecked(!isChecked); url.setEnabled(!isChecked); url.setChecked(true); gmap.setEnabled(!isChecked); gmap.setChecked(!isChecked); nourl.setEnabled(!isChecked); nourl.setChecked(!isChecked); } }); return new AlertDialog.Builder(this).setTitle(R.string.app_name).setView(sharedMapView) .setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { finish(); } }).setNeutralButton(R.string.options, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { /* needed to display neutral button */ } }).setPositiveButton(R.string.share_it, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { final boolean isLatLong = ((CheckBox) sharedMapView .findViewById(R.id.add_lat_lon_location)).isChecked(); final boolean isGeocodeAddress = ((CheckBox) sharedMapView .findViewById(R.id.add_address_location)).isChecked(); final boolean isUrl = ((RadioButton) sharedMapView.findViewById(R.id.add_url_location)) .isChecked(); final boolean isGmap = ((RadioButton) sharedMapView .findViewById(R.id.add_native_location)).isChecked(); final EditText body = (EditText) sharedMapView.findViewById(R.id.body); final boolean isTracked = ((ToggleButton) sharedMapView .findViewById(R.id.add_track_location)).isChecked(); final String uuid = UUID.randomUUID().toString(); pref.edit().putBoolean(PREF_LAT_LON_CHECKED, isLatLong) .putBoolean(PREF_ADDRESS_CHECKED, isGeocodeAddress) .putBoolean(PREF_URL_CHECKED, isUrl).putBoolean(PREF_GMAP_CHECKED, isGmap) .putString(PREF_BODY_DEFAULT, body.getText().toString()) .putBoolean(PREF_TRACK_CHECKED, isTracked).commit(); final Intent t = new Intent(Intent.ACTION_SEND); t.setType("text/plain"); t.addCategory(Intent.CATEGORY_DEFAULT); final Intent share = Intent.createChooser(t, getString(R.string.app_name)); final GeoPoint p = sharedMap.getMapCenter(); final String text = body.getText().toString(); share(p.getLatitude(), p.getLongitude(), t, share, text, isGeocodeAddress, isUrl, isGmap, isLatLong, isTracked, uuid); } }).create(); case PROGRESS_DLG: final ProgressDialog dlg = new ProgressDialog(this); dlg.setTitle(getText(R.string.app_name)); dlg.setMessage(getText(R.string.progression_desc)); dlg.setIndeterminate(true); dlg.setCancelable(true); dlg.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); return dlg; case PROVIDERS_DLG: return new AlertDialog.Builder(this).setTitle(R.string.app_name).setCancelable(false) .setIcon(android.R.drawable.ic_menu_help).setMessage(R.string.providers_needed) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent gpsProperty = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(gpsProperty); } }).create(); } }
From source file:uk.co.senab.photup.PhotoViewerActivity.java
private void showCaptionDialog() { final PhotoUpload currentUpload = getCurrentUpload(); if (null != currentUpload) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.photo_caption); builder.setIcon(R.drawable.ic_action_caption); // Set an EditText view to get user input final FrameLayout layout = new FrameLayout(this); final int margin = getResources().getDimensionPixelSize(R.dimen.spacing); layout.setPadding(margin, margin, margin, margin); final EditText input = new EditText(this); input.setMinLines(2);/*from w ww .j a v a2s . com*/ input.setText(currentUpload.getCaption()); layout.addView(input); builder.setView(layout); final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { switch (whichButton) { case AlertDialog.BUTTON_POSITIVE: currentUpload.setCaption(input.getText().toString()); getSupportActionBar().setTitle(currentUpload.toString()); break; case AlertDialog.BUTTON_NEGATIVE: default: dialog.dismiss(); break; } } }; builder.setPositiveButton(android.R.string.ok, listener); builder.setNegativeButton(android.R.string.cancel, listener); builder.show(); } }
From source file:org.quantumbadger.redreader.fragments.CommentListingFragment.java
public CommentListingFragment(final AppCompatActivity parent, final Bundle savedInstanceState, final ArrayList<RedditURLParser.RedditURL> urls, final UUID session, final String searchString, final boolean forceDownload) { super(parent, savedInstanceState); if (savedInstanceState != null) { mPreviousFirstVisibleItemPosition = savedInstanceState.getInt(SAVEDSTATE_FIRST_VISIBLE_POS); }//from w w w . j a va 2 s . c o m mCommentListingManager = new FilteredCommentListingManager(parent, searchString); mAllUrls = urls; mUrlsToDownload = new LinkedList<>(mAllUrls); this.mSession = session; if (forceDownload) { mDownloadStrategy = DownloadStrategyAlways.INSTANCE; } else { mDownloadStrategy = DownloadStrategyIfNotCached.INSTANCE; } mUser = RedditAccountManager.getInstance(getActivity()).getDefaultAccount(); parent.invalidateOptionsMenu(); final Context context = getActivity(); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); mCommentFontScale = PrefsUtility.appearance_fontscale_comments(context, prefs); mShowLinkButtons = PrefsUtility.pref_appearance_linkbuttons(context, prefs); mOuterFrame = new FrameLayout(context); final ScrollbarRecyclerViewManager recyclerViewManager = new ScrollbarRecyclerViewManager(context, null, false); if (parent instanceof OptionsMenuUtility.OptionsMenuCommentsListener && PrefsUtility.pref_behaviour_enable_swipe_refresh(context, prefs)) { recyclerViewManager.enablePullToRefresh(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { ((OptionsMenuUtility.OptionsMenuCommentsListener) parent).onRefreshComments(); } }); } mRecyclerView = recyclerViewManager.getRecyclerView(); mCommentListingManager.setLayoutManager((LinearLayoutManager) mRecyclerView.getLayoutManager()); mRecyclerView.setAdapter(mCommentListingManager.getAdapter()); mOuterFrame.addView(recyclerViewManager.getOuterView()); mRecyclerView.setItemAnimator(null); /* TODO { final RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator(); itemAnimator.setRemoveDuration(80); itemAnimator.setChangeDuration(80); itemAnimator.setAddDuration(80); itemAnimator.setMoveDuration(80); } */ if (!PrefsUtility.pref_appearance_comments_show_floating_toolbar(context, prefs)) { mFloatingToolbar = null; } else { mFloatingToolbar = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.floating_toolbar, mOuterFrame, false); // We need a container so that setVisible() doesn't mess with the Z-order final FrameLayout floatingToolbarContainer = new FrameLayout(context); floatingToolbarContainer.addView(mFloatingToolbar); mOuterFrame.addView(floatingToolbarContainer); if (PrefsUtility.isNightMode(context)) { mFloatingToolbar.setBackgroundColor(Color.argb(0xCC, 0x33, 0x33, 0x33)); } final int buttonVPadding = General.dpToPixels(context, 12); final int buttonHPadding = General.dpToPixels(context, 16); { final ImageButton previousButton = (ImageButton) LayoutInflater.from(context) .inflate(R.layout.flat_image_button, mFloatingToolbar, false); previousButton.setPadding(buttonHPadding, buttonVPadding, buttonHPadding, buttonVPadding); previousButton.setImageResource(R.drawable.ic_ff_up_dark); previousButton.setContentDescription(getString(R.string.button_prev_comment_parent)); mFloatingToolbar.addView(previousButton); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView .getLayoutManager(); for (int pos = layoutManager.findFirstVisibleItemPosition() - 1; pos > 0; pos--) { final GroupedRecyclerViewAdapter.Item item = mCommentListingManager .getItemAtPosition(pos); if (item instanceof RedditCommentListItem && ((RedditCommentListItem) item).isComment() && ((RedditCommentListItem) item).getIndent() == 0) { layoutManager.scrollToPositionWithOffset(pos, 0); return; } } layoutManager.scrollToPositionWithOffset(0, 0); } }); previousButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(final View view) { General.quickToast(context, R.string.button_prev_comment_parent); return true; } }); } { final ImageButton nextButton = (ImageButton) LayoutInflater.from(context) .inflate(R.layout.flat_image_button, mFloatingToolbar, false); nextButton.setPadding(buttonHPadding, buttonVPadding, buttonHPadding, buttonVPadding); nextButton.setImageResource(R.drawable.ic_ff_down_dark); nextButton.setContentDescription(getString(R.string.button_next_comment_parent)); mFloatingToolbar.addView(nextButton); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView .getLayoutManager(); for (int pos = layoutManager.findFirstVisibleItemPosition() + 1; pos < layoutManager .getItemCount(); pos++) { final GroupedRecyclerViewAdapter.Item item = mCommentListingManager .getItemAtPosition(pos); if (item instanceof RedditCommentListItem && ((RedditCommentListItem) item).isComment() && ((RedditCommentListItem) item).getIndent() == 0) { layoutManager.scrollToPositionWithOffset(pos, 0); break; } } } }); nextButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(final View view) { General.quickToast(context, R.string.button_next_comment_parent); return true; } }); } } final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(context); final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(context, new BezelSwipeOverlay.BezelSwipeListener() { @Override public boolean onSwipe(@BezelSwipeOverlay.SwipeEdge int edge) { if (mPost == null) return false; toolbarOverlay.setContents(mPost.generateToolbar(getActivity(), true, toolbarOverlay)); toolbarOverlay .show(edge == BezelSwipeOverlay.LEFT ? SideToolbarOverlay.SideToolbarPosition.LEFT : SideToolbarOverlay.SideToolbarPosition.RIGHT); return true; } public boolean onTap() { if (toolbarOverlay.isShown()) { toolbarOverlay.hide(); return true; } return false; } }); mOuterFrame.addView(bezelOverlay); mOuterFrame.addView(toolbarOverlay); bezelOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; bezelOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; toolbarOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; toolbarOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT; makeNextRequest(context); }
From source file:com.jinzht.pro.view.RecyclerViewHeader.java
private void setupAlignment(RecyclerView recycler) { if (!mAlreadyAligned) { //setting alignment of header ViewGroup.LayoutParams currentParams = getLayoutParams(); FrameLayout.LayoutParams newHeaderParams; int width = ViewGroup.LayoutParams.WRAP_CONTENT; int height = ViewGroup.LayoutParams.WRAP_CONTENT; int gravity = (mReversed ? Gravity.BOTTOM : Gravity.TOP) | Gravity.CENTER_HORIZONTAL; if (currentParams != null) { newHeaderParams = new FrameLayout.LayoutParams(getLayoutParams()); //to copy all the margins newHeaderParams.width = width; newHeaderParams.height = height; newHeaderParams.gravity = gravity; } else {/*from w w w . ja v a 2 s . c om*/ newHeaderParams = new FrameLayout.LayoutParams(width, height, gravity); } RecyclerViewHeader.this.setLayoutParams(newHeaderParams); //setting alignment of recycler FrameLayout newRootParent = new FrameLayout(recycler.getContext()); newRootParent.setLayoutParams(recycler.getLayoutParams()); ViewParent currentParent = recycler.getParent(); if (currentParent instanceof ViewGroup) { int indexWithinParent = ((ViewGroup) currentParent).indexOfChild(recycler); ((ViewGroup) currentParent).removeViewAt(indexWithinParent); recycler.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); newRootParent.addView(recycler); newRootParent.addView(RecyclerViewHeader.this); ((ViewGroup) currentParent).addView(newRootParent, indexWithinParent); } } }
From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final SRThemeAttributes attr = new SRThemeAttributes(context); mPost = post;//from w w w. j av a2s.c o m isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.srMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && SRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, SRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }
From source file:com.taobao.weex.ui.component.WXSliderNeighbor.java
@Override protected void addSubView(View view, final int index) { if (view == null || mAdapter == null) { return;// w w w .j ava 2 s .c o m } if (view instanceof WXCircleIndicator) { return; } FrameLayout wrapper = new FrameLayout(getContext()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; view.setLayoutParams(params); wrapper.addView(view); super.addSubView(wrapper, index); updateAdapterScaleAndAlpha(mNeighborAlpha, mNeighborScale); // we need to set neighbor view status when added. mViewPager.postDelayed(WXThread.secure(new Runnable() { @Override public void run() { try { if (mViewPager.getRealCount() > 0 && index > 2) { // index > 2 mean more than two times, then need a fake drag // prevent a bug of init status. ZoomTransformer no called as excepted. mViewPager.beginFakeDrag(); mViewPager.fakeDragBy(1); // must be 1 } } catch (IndexOutOfBoundsException e) { // do nothing } finally { try { mViewPager.endFakeDrag(); } catch (Exception e) { // do nothing } } } }), 50); }
From source file:com.fibrobook.viewpager.custom.CardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/* w w w . java 2 s.c o m*/ final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); LinearLayout l = new LinearLayout(getActivity()); params.setMargins(margin, margin, margin, margin); l.setLayoutParams(params); l.setGravity(Gravity.CENTER); l.setBackgroundResource(R.drawable.background_card); switch (position) { case 0: symphtomsView(l); break; case 1: dayView(l); break; } fl.addView(l); return fl; }
From source file:comm.lib.photoview.PhotoViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new HackyViewPager(this); setContentView(R.layout.show_image_vp); FrameLayout vgViewPager = (FrameLayout) findViewById(R.id.show_image_vg_viewpager); indexTextView = (TextView) findViewById(R.id.show_image_index); back = (ImageView) findViewById(R.id.show_image_back); downloadToolBar = (RelativeLayout) findViewById(R.id.show_image_download); downLoadProgress = (ProgressBar) findViewById(R.id.show_image_progressbar); original = (TextView) findViewById(R.id.show_image_original); original.setOnClickListener(this); note = (TextView) findViewById(R.id.show_image_note); vgViewPager.addView(mViewPager); Intent intent = getIntent();/*ww w . jav a 2 s . co m*/ if (intent != null) { currIndex = intent.getIntExtra(CURR_INDEX, 0); sDrawables = intent.getStringArrayListExtra(URLS); } else { this.finish(); } mViewPager.setAdapter(new SamplePagerAdapter()); mViewPager.setCurrentItem(currIndex); indexTextView.setText(String.valueOf(currIndex + 1)); mViewPager.setOnPageChangeListener(this); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PhotoViewActivity.this.finish(); } }); downloadManager = new DownloadManager(this); iSql = new ISqlImpl(this); initDownLoadTask(currIndex); }
From source file:uk.co.armedpineapple.cth.SDLActivity.java
void loadApplication() { // Load the libraries System.loadLibrary("SDL"); System.loadLibrary("luajit"); System.loadLibrary("SDL_mixer"); System.loadLibrary("ffmpeg"); System.loadLibrary("appmain"); try {/*from w ww . java2s . co m*/ app.configuration.writeToFile(); } catch (IOException e) { e.printStackTrace(); Log.e(LOG_TAG, "Couldn't write to configuration file"); BugSenseHandler.sendException(e); } File f = new File(app.configuration.getSaveGamesPath()); if (!f.isDirectory()) { f.mkdirs(); } // So we can call stuff from static callbacks mSingleton = this; hideSystemUi(); mSurface = new SDLSurface(this, app.configuration.getDisplayWidth(), app.configuration.getDisplayHeight()); mSurface.setZOrderOnTop(false); DrawerLayout mainLayout = (DrawerLayout) getLayoutInflater().inflate(R.layout.game, null); FrameLayout gameFrame = ((FrameLayout) mainLayout.findViewById(R.id.game_frame)); gameFrame.addView(mSurface); setContentView(mainLayout); mHapticLauncher = new Launcher(this); mDrawerLayout = (DrawerLayout) findViewById(R.id.main_layout); mDrawerList = (ListView) findViewById(R.id.menu_drawer); mDrawerList.setAdapter(new NavDrawerAdapter(this, uk.co.armedpineapple.cth.MenuItems.getItems(BuildConfig.DEBUG || app.configuration.getDebug()))); mDrawerList.setOnItemClickListener(new NavDrawerListListener(this)); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); mDrawerLayout.setDrawerListener(new DrawerListener() { @Override public void onDrawerClosed(View arg0) { // Restore game speed cthGameSpeed(app.configuration.getGameSpeed()); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); } @Override public void onDrawerOpened(View arg0) { // Pause the game cthGameSpeed(0); } @Override public void onDrawerSlide(View arg0, float arg1) { arg0.bringToFront(); mDrawerLayout.bringChildToFront(arg0); mDrawerLayout.requestLayout(); } @Override public void onDrawerStateChanged(int arg0) { // TODO Auto-generated method stub } }); SurfaceHolder holder = mSurface.getHolder(); holder.setFixedSize(app.configuration.getDisplayWidth(), app.configuration.getDisplayHeight()); gameFrame.setVisibility(View.VISIBLE); hasGameLoaded = true; }