@Override public boolean onOptionsItemSelected(MenuItem item) { // hide action bar ActionBar actionBar = getSupportActionBar(); if (actionBar != null) actionBar.hide(); // hide keyboard View view = this.getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } // begin transaction FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Handle item selection switch (item.getItemId()) { case R.id.action_settings: Fragment settingsFragment = new SettingsFragment(); transaction.replace(android.R.id.content, settingsFragment); transaction.addToBackStack(null); transaction.commit(); return true; case R.id.about_project: Fragment aboutFragment = new AboutFragment(); transaction.replace(android.R.id.content, aboutFragment); transaction.addToBackStack(null); transaction.commit(); return true; default: return super.onOptionsItemSelected(item); } }
public void updateActionBar(final ActionBar actionBar) { // Hide the action bar for contact picker mode. The custom ToolBar containing chips UI // etc. will take the spot of the action bar. actionBar.hide(); UiUtils.setStatusBarColor( getActivity(), getResources().getColor(R.color.compose_notification_bar_background)); }
/** * 消息分发,选择跳转到哪个fragment * * @param intent */ private void enterFragment(Intent intent) { String tag = null; if (intent != null) { Fragment fragment = null; if (intent.getExtras() != null && intent.getExtras().containsKey(RongConst.EXTRA.CONTENT)) { String fragmentName = intent.getExtras().getString(RongConst.EXTRA.CONTENT); fragment = Fragment.instantiate(this, fragmentName); } else if (intent.getData() != null) { if (intent.getData().getPathSegments().get(0).equals("conversation")) { tag = "conversation"; String fragmentName = ConversationFragment.class.getCanonicalName(); fragment = Fragment.instantiate(this, fragmentName); } else if (intent.getData().getLastPathSegment().equals("conversationlist")) { tag = "conversationlist"; String fragmentName = ConversationListFragment.class.getCanonicalName(); fragment = Fragment.instantiate(this, fragmentName); } else if (intent.getData().getLastPathSegment().equals("subconversationlist")) { tag = "subconversationlist"; String fragmentName = SubConversationListFragment.class.getCanonicalName(); fragment = Fragment.instantiate(this, fragmentName); SubConversationListFragment sub = (SubConversationListFragment) fragment; sub.setAdapter(new SubConversationListAdapterEx(RongContext.getInstance())); } else if (intent.getData().getPathSegments().get(0).equals("friend")) { tag = "friend"; String fragmentName = FriendMultiChoiceFragment.class.getCanonicalName(); fragment = Fragment.instantiate(this, fragmentName); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); // 隐藏ActionBar } targetId = intent.getData().getQueryParameter("targetId"); targetIds = intent.getData().getQueryParameter("targetIds"); mDiscussionId = intent.getData().getQueryParameter("discussionId"); if (targetId != null) { mConversationType = Conversation.ConversationType.valueOf( intent.getData().getLastPathSegment().toUpperCase(Locale.getDefault())); } else if (targetIds != null) { mConversationType = Conversation.ConversationType.valueOf( intent.getData().getLastPathSegment().toUpperCase(Locale.getDefault())); } } if ("tag".equals(tag)) { showRealTimeLocationBar(null); // RealTimeLocation } if (fragment != null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.de_content, fragment, tag); transaction.addToBackStack(null).commitAllowingStateLoss(); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_launch); mAContext = this; mContentView = findViewById(R.id.fullscreen_content); // Hide UI first ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } // Remove the status and navigation bar if (Build.VERSION.SDK_INT < 14) return; mContentView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); if (Small.getIsNewHostApp()) { TextView tvPrepare = (TextView) findViewById(R.id.prepare_text); tvPrepare.setVisibility(View.VISIBLE); } }
@Override public void onCustomViewShown() { // full screen video has just been shown so hide the ActionBar ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.hide(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_contacts_list); android.support.v7.app.ActionBar mActionBar = getSupportActionBar(); mActionBar.hide(); initView(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fullscreen_lock); this.getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } Intent intent = getIntent(); String name = intent.getStringExtra("key"); gName = name; Log.d("JKS", "app data received is " + name); MainActivity.lockApp(name); try { final PackageManager pm = getPackageManager(); Drawable icon = pm.getApplicationIcon(name); ImageView img_icon = (ImageView) findViewById(R.id.img_icon); img_icon.setImageDrawable(icon); // imageView.setImageResource(imageId[position]); } catch (Exception ex) { Log.d("JKS", "Exceptions CAUGHT"); } lockedApp = name; // mVisible = true; // mControlsView = findViewById(R.id.fullscreen_content_controls); // Set up the user interaction to manually show or hide the system UI. /* mContentView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggle(); } }); */ // Upon interacting with UI controls, delay any scheduled hide() // operations to prevent the jarring behavior of controls going away // while interacting with the UI. // findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener); findViewById(R.id.btn_unlock) .setOnClickListener( new View.OnClickListener() { public void onClick(View v) { // Perform action on click finish(); MainActivity.unlockApp(lockedApp); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); aq = new AQuery(CarClassesActivity.this); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); GOS.setCurrency(GodObject.Currency.RUB); init(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_codigo_activacion); editCodigoActivacion = (EditText) findViewById(R.id.editCodigoActivacion); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); }
@Override public boolean onCreateOptionsMenu(Menu menu) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; }
@Override protected void onPostCreate(Bundle savedInstanceState) { // hides the top bar super.onPostCreate(savedInstanceState); mControlsView.setVisibility(View.GONE); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } }
@Override protected void onCreate(Bundle savedInstanceState) { // Hide Navigation/Status/Action bars int UI_OPTIONS = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; getWindow().getDecorView().setSystemUiVisibility(UI_OPTIONS); super.onCreate(savedInstanceState); ActionBar ab = getSupportActionBar(); if (ab != null) ab.hide(); setContentView(R.layout.activity_main); iv = (ImageView) findViewById(R.id.iv); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getRealSize(size); float dw = size.x; float dh = size.y; maxY = (float) (dh * 0.65); bitmap = Bitmap.createBitmap((int) dw, (int) dh, Bitmap.Config.ARGB_8888); canvas = new Canvas(bitmap); paint = new Paint(); paint.setColor(Color.BLUE); paint.setStrokeWidth((float) 3); iv.setImageBitmap(bitmap); // horizontal canvas.drawLine((float) 0, maxY, dw, maxY, paint); iv.invalidate(); // vertical canvas.drawLine((float) (dw * 0.125), 0, (float) (dw * 0.125), dh, paint); iv.invalidate(); canvas.drawLine((float) (dw * 0.375), 0, (float) (dw * 0.375), dh, paint); iv.invalidate(); canvas.drawLine((float) (dw * 0.625), 0, (float) (dw * 0.625), dh, paint); iv.invalidate(); canvas.drawLine((float) (dw * 0.875), 0, (float) (dw * 0.875), dh, paint); iv.invalidate(); P1 = new PointF((float) (dw * 0.125) + 5, maxY - 5); P2 = new PointF((float) (dw * 0.375) + 5, maxY - 5); P3 = new PointF((float) (dw * 0.625) + 5, maxY - 5); P4 = new PointF((float) (dw * 0.875) + 5, maxY - 5); paint.setColor(Color.RED); canvas.drawLine(P1.x, P1.y, P4.x, P4.y, paint); iv.invalidate(); startNotification(); }
public void setContentEditingModeVisible(boolean isVisible) { if (!isAdded()) { return; } ActionBar actionBar = getActionBar(); if (isVisible) { Animation fadeAnimation = new AlphaAnimation(1, 0); fadeAnimation.setDuration(CONTENT_ANIMATION_DURATION); fadeAnimation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mTitleEditText.setVisibility(View.GONE); } @Override public void onAnimationEnd(Animation animation) { mPostSettingsLinearLayout.setVisibility(View.GONE); mFormatBar.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) {} }); mPostContentLinearLayout.startAnimation(fadeAnimation); if (actionBar != null) { actionBar.hide(); } } else { mTitleEditText.setVisibility(View.VISIBLE); mFormatBar.setVisibility(View.GONE); Animation fadeAnimation = new AlphaAnimation(0, 1); fadeAnimation.setDuration(CONTENT_ANIMATION_DURATION); fadeAnimation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { mPostSettingsLinearLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) {} }); mPostContentLinearLayout.startAnimation(fadeAnimation); getActivity().invalidateOptionsMenu(); if (actionBar != null) { actionBar.show(); } } }
private void hide() { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } mControlsView.setVisibility(View.GONE); mVisible = false; mHideHandler.removeCallbacks(mShowPart2Runnable); mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY); }
@Override protected void onCreate(Bundle savedInstanceState) { boolean b = requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.internet); if (checkInternetConnection()) { setContentView(R.layout.activity_website_clone); wv = (WebView) findViewById(R.id.webview); wv.setWebViewClient( new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.substring(0, 7).equals("file://")) { return false; } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); } return true; } }); wv.setWebChromeClient(new WebChromeClient()); wv.getSettings().setJavaScriptEnabled(true); // TODO:If network conn available load from net. wv.loadUrl(getString(R.string.websiteURL)); // Adding JS Interface // Code on the Website index: /*<script> App.showToast("Hello from WebSite"); </script>*/ // TODO:Add functionality to display notification on demand from website wv.addJavascriptInterface(new WebAppInterface(context), "App"); } else { refreshb = (Button) findViewById(R.id.refreshButton); refreshb.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (checkInternetConnection()) { setContentView(R.layout.activity_website_clone); Intent intent = getIntent(); finish(); startActivity(intent); } } }); } ActionBar actionBar = getSupportActionBar(); try { actionBar.hide(); } catch (java.lang.NullPointerException e) { Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); } }
@Override protected void onCreate(Bundle savedInstanceState) { // Erase the title bar requestWindowFeature(Window.FEATURE_NO_TITLE); // Make it full Screen getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.activity_start_game); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); }
private void hide() { // Hide UI first ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } // Schedule a runnable to remove the status and navigation bar after a delay mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY); }
private void toggleActionBar() { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (actionBar.isShowing()) { actionBar.hide(); } else { actionBar.show(); } } }
private void hide() { // Hide UI first ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } mControlsView.setVisibility(View.GONE); mVisible = false; // Schedule a runnable to remove the status and navigation bar after a delay mHideHandler.removeCallbacks(mShowPart2Runnable); mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY); }
@Override public void onResume() { super.onResume(); if (mActionBar != null) { mActionBar.hide(); } mActivity.setLightsOutMode(true); if (!mApplication.getEventBus().isRegistered(this)) { mApplication.getEventBus().register(this); } mSlideshowHandler.postDelayed(mSlideshowAction, SLIDESHOW_INTERVAL_MS); mController.updateStatus(PlayStatus.PLAYING, mBucketId); }
private void initToolbar() { // 액션바 객체 생성 android.support.v7.app.ActionBar actionBar = getSupportActionBar(); // 액션바 설정 actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); // 액션바 숨김 actionBar.hide(); // 툴바 설정 mToolBar = (Toolbar) findViewById(R.id.main_toolbar); mToolBar.setContentInsetsAbsolute(0, 0); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about_jia_yu); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); initView(); versionUpdata(); if (savedInstanceState == null) { getSupportFragmentManager() .beginTransaction() .add(R.id.container, new PlaceholderFragment()) .commit(); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_loading, container, false); ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar(); actionBar.hide(); cover = (ImageView) view.findViewById(R.id.layout_cover); ((TextView) view.findViewById(R.id.text_loading)) .setTypeface(TypefaceCache.get(TypefaceCache.FONT_MUSEO_500)); colorize(); return view; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tutorial); Button buttonViewTutorial = (Button) findViewById(R.id.buttonViewTutorial); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } buttonViewTutorial.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { loadTutorial(); } }); }
public static void hideActionBar(ActionBarActivity context) { if (Build.VERSION.SDK_INT < 16) { context .getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else if (Build.VERSION.SDK_INT > 16) { View decorView = context.getWindow().getDecorView(); // Hide the status bar. int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); // Remember that you should never show the action bar if the // status bar is hidden, so hide that too if necessary. ActionBar actionBar = context.getSupportActionBar(); actionBar.hide(); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); switch (id) { case R.id.action_settings: Toast.makeText(this, "Settings not yet implemented", Toast.LENGTH_SHORT).show(); break; case R.id.hide_actionbar: Toast.makeText(this, "Action Bar Hidden", Toast.LENGTH_SHORT).show(); android.support.v7.app.ActionBar actionBar = getSupportActionBar(); actionBar.hide(); break; default: break; } return true; }
protected void initView() { ActionBar actionBar = getSupportActionBar(); actionBar.hide(); mSoftManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mUserInfosDao = DBManager.getInstance(LoginActivity.this).getDaoSession().getUserInfosDao(); mLoginImg = (ImageView) findViewById(R.id.de_login_logo); mUserNameEt = (EditText) findViewById(R.id.app_username_et); mPassWordEt = (EditText) findViewById(R.id.app_password_et); mSignInBt = (Button) findViewById(R.id.app_sign_in_bt); mRegister = (TextView) findViewById(R.id.de_login_register); mFogotPassWord = (TextView) findViewById(R.id.de_login_forgot); mImgBackgroud = (ImageView) findViewById(R.id.de_img_backgroud); mFrUserNameDelete = (FrameLayout) findViewById(R.id.fr_username_delete); mFrPasswordDelete = (FrameLayout) findViewById(R.id.fr_pass_delete); mIsShowTitle = (RelativeLayout) findViewById(R.id.de_merge_rel); mLeftTitle = (TextView) findViewById(R.id.de_left); mRightTitle = (TextView) findViewById(R.id.de_right); mUserList = new ArrayList<User>(); mResultList = new ArrayList<ApiResult>(); mSignInBt.setOnClickListener(this); mRegister.setOnClickListener(this); mLeftTitle.setOnClickListener(this); mRightTitle.setOnClickListener(this); mHandler = new Handler(this); mDialog = new LoadingDialog(this); mEditUserNameEt = new EditTextHolder(mUserNameEt, mFrUserNameDelete, null); mEditPassWordEt = new EditTextHolder(mPassWordEt, mFrPasswordDelete, null); mHandler.post( new Runnable() { @Override public void run() { Animation animation = AnimationUtils.loadAnimation(LoginActivity.this, R.anim.translate_anim); mImgBackgroud.startAnimation(animation); } }); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); } decentBanner = (DecentBanner) findViewById(R.id.decent_banner); View view1 = getLayoutInflater().inflate(R.layout.popular_layout, null); View view2 = getLayoutInflater().inflate(R.layout.daily_layout, null); View view3 = getLayoutInflater().inflate(R.layout.recommend_layout, null); views = new ArrayList<>(); views.add(view1); views.add(view2); views.add(view3); titles = new ArrayList<>(); titles.add("POPULAR"); titles.add("IMAGE"); titles.add("RECOMMEND"); decentBanner.start(views, titles, 2, 500, R.drawable.logo); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left); setContentView(R.layout.activity_shop_screen); // Hide status bar getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); // Hide the action bar ActionBar actionBar = getSupportActionBar(); actionBar.hide(); MainLayout = (LinearLayout) findViewById(R.id.main_layout); MainLayout.setBackgroundResource(R.drawable.background); // Set opacity on background_coin ImageView img = (ImageView) findViewById(R.id.background_coin); img.setImageAlpha(85); final Button usables = (Button) findViewById(R.id.usablebtn); final Button cosmetic = (Button) findViewById(R.id.Cosmeticbtn); usables.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (!FragUsable.isVisible()) { cosmetic.setBackgroundResource(R.drawable.buttonmenu); cosmetic.setTextColor(Color.WHITE); usables.setBackgroundResource(R.drawable.buttonpressed); usables.setTextColor(Color.parseColor("#ce492b")); FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.setCustomAnimations(R.animator.slide_in_left, R.animator.slide_out_right); ft.replace(R.id.fragment_place, FragUsable); ft.commit(); } } }); cosmetic.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (!FragCosmetic.isVisible()) { usables.setBackgroundResource(R.drawable.buttonmenu); usables.setTextColor(Color.WHITE); cosmetic.setBackgroundResource(R.drawable.buttonpressed); cosmetic.setTextColor(Color.parseColor("#ce492b")); FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.setCustomAnimations(R.animator.slide_in_right, R.animator.slide_out_left); ft.replace(R.id.fragment_place, FragCosmetic); ft.commit(); } } }); TextView goldText = (TextView) findViewById(R.id.editText); Button Cosmeticbtn = (Button) findViewById(R.id.Cosmeticbtn); Button usablebtn = (Button) findViewById(R.id.usablebtn); FontsOverride.setTextViewFont(this, goldText); FontsOverride.setButtonFont(this, Cosmeticbtn); FontsOverride.setButtonFont(this, usablebtn); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // to hide the action bar setContentView(R.layout.ui_user_page); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); uiuser_youthfacts = (Button) findViewById(R.id.uiuser_youthfacts); uiuser_youthfacts.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { startCategories(); } }); uiuser_youthprogram = (Button) findViewById(R.id.uiuser_youthprogram); uiuser_youthprogram.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { startSearch(); } }); uiuser_newuser = (Button) findViewById(R.id.uiuser_newuser); uiuser_newuser.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { startNewUser(); } }); uiuser_existinguser = (Button) findViewById(R.id.uiuser_existinguser); uiuser_existinguser.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getApplicationContext(), ExistingParentActivity.class); startActivity(intent); } }); uiuser_checkin = (Button) findViewById(R.id.uiuser_checkin); uiuser_checkin.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate( R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root)); TextView text = (TextView) layout.findViewById(R.id.text); text.setText("Coming Soon to Communities Near You"); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); } }); }