List of usage examples for android.widget Toast getView
public View getView()
From source file:org.openobservatory.ooniprobe.activity.MainActivity.java
@Override public void update(Observable observable, Object data) { updateActionBar();/*from w w w . j a va 2s. co m*/ //update the fragments RunTestsFragment runTestsFragment = (RunTestsFragment) getSupportFragmentManager() .findFragmentByTag("run_tests"); if (runTestsFragment != null && runTestsFragment.isVisible()) { runTestsFragment.updateList(); } PastTestsFragment pastTestsFragment = (PastTestsFragment) getSupportFragmentManager() .findFragmentByTag("past_tests"); if (pastTestsFragment != null && pastTestsFragment.isVisible()) { pastTestsFragment.updateList(); } TestInfoFragment testInfoFragment = (TestInfoFragment) getSupportFragmentManager() .findFragmentByTag("test_info"); if (testInfoFragment != null && testInfoFragment.isVisible()) { testInfoFragment.updateButtons(); } if (data != null && data instanceof String) { String string = NetworkMeasurement.getTestName(this, (String) data) + " " + getString(R.string.test_name_finished); Toast toast = Toast.makeText(this, string, Toast.LENGTH_LONG); View view = toast.getView(); TextView text = (TextView) view.findViewById(android.R.id.message); text.setGravity(Gravity.CENTER); ; toast.show(); } System.out.println("update " + observable); }
From source file:za.ac.uct.cs.lwsjam005.eshelf.activities.ReadActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); thisBook = (Book) extras.getSerializable(ARG_BOOK); currentPage = thisBook.getCurrentPage(); setContentView(R.layout.activity_read); setupActionBar();/*w w w . j av a2s . c o m*/ // Instantiate a ViewPager and a PagerAdapter. mPager = (ViewPager) findViewById(R.id.read_pager); mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter); mPager.setCurrentItem(currentPage); mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { currentPage = position; Toast t = Toast.makeText(getApplicationContext(), (position + 1) + "/" + NUM_PAGES, Toast.LENGTH_SHORT); t.getView().setBackgroundColor(Color.parseColor("#33000088")); t.show(); invalidateOptionsMenu(); } }); }
From source file:httbdd.cse.nghiatran.halofind.screen.MainActivity.java
@Override public void onBackPressed() { if (mDoubleBackToExitPressedOnce) { super.onBackPressed(); StartActivity.REMEMBER_ME = true; return;// w w w. jav a 2s .com } mDoubleBackToExitPressedOnce = true; Toast toast = Toast.makeText(this, getString(R.string.press_back_again_to_exit), Toast.LENGTH_SHORT); TextView v = (TextView) toast.getView().findViewById(android.R.id.message); v.setTextColor(Color.WHITE); toast.show(); new Handler().postDelayed(new Runnable() { @Override public void run() { mDoubleBackToExitPressedOnce = false; //reset mDoubleBackToExitPressedOnce to false after 2 seconds } }, 2000); }
From source file:com.github.andrewlord1990.snackbarbuilder.toastbuilder.ToastBuilder.java
private TextView setupToastView(Toast toast) { if (customView != null) { toast.setView(customView);//w ww. j a v a2s . c o m TextView messageView = setCustomViewMessage(); if (messageView != null) { return messageView; } } return getToastMessageView(toast.getView()); }
From source file:edu.Groove9.TunesMaster.songplayer.SongPlayerFragment.java
public void showError(String error) { Toast toast = Toast.makeText(getActivity().getApplicationContext(), error, Toast.LENGTH_LONG); TextView v = (TextView) toast.getView().findViewById(android.R.id.message); v.setTextColor(Color.RED);/* w w w . j a v a 2 s . c om*/ toast.show(); }
From source file:io.oceanos.shaderbox.ShaderEditorActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final LayoutInflater inflater = getLayoutInflater(); final View customActionBarView = inflater.inflate(R.layout.actionbar_view_save, null); final View shaderActionView = customActionBarView.findViewById(R.id.actionbar_view); final View shaderActionSave = customActionBarView.findViewById(R.id.actionbar_save); shaderActionView.setOnClickListener(new View.OnClickListener() { @Override//from w w w .j av a 2s.c o m public void onClick(View v) { if (result.isSuccess()) onView(shader); else { Toast errorMsg = Toast.makeText(getBaseContext(), result.getError(), Toast.LENGTH_LONG); errorMsg.getView().setBackgroundColor(getResources().getColor(R.color.editor_color_error)); errorMsg.show(); } } }); shaderActionSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSave(shader); } }); fps = (TextView) customActionBarView.findViewById(R.id.text_fps); viewError = (TextView) shaderActionView.findViewById(R.id.viewError); final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); setContentView(R.layout.activity_editor); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); ShaderDatabase database = new ShaderDatabase(getBaseContext()); if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); long id = database.newShader(); Cursor cursor = database.findById(id); if (cursor.moveToFirst()) shader = Shader.getValues(cursor); cursor.close(); if (sharedText != null) shader.setText(sharedText); else shader.setText(""); } } else { long id = intent.getLongExtra("ID", 0); Cursor cursor = database.findById(id); if (cursor.moveToFirst()) shader = Shader.getValues(cursor); cursor.close(); } database.close(); setSymbolListener(R.id.action_tab, '\t'); setSymbolListener(R.id.action_rpo, '('); setSymbolListener(R.id.action_rpc, ')'); setSymbolListener(R.id.action_cpo, '{'); setSymbolListener(R.id.action_cpc, '}'); setSymbolListener(R.id.action_dotcoma, ';'); setSymbolListener(R.id.action_coma, ','); setSymbolListener(R.id.action_dot, '.'); setSymbolListener(R.id.action_plus, '+'); setSymbolListener(R.id.action_minus, '-'); setSymbolListener(R.id.action_times, '*'); setSymbolListener(R.id.action_div, '/'); setSymbolListener(R.id.action_equal, '='); setSymbolListener(R.id.action_spo, '['); setSymbolListener(R.id.action_spc, ']'); setSymbolListener(R.id.action_and, '&'); setSymbolListener(R.id.action_or, '|'); setSymbolListener(R.id.action_greater, '>'); setSymbolListener(R.id.action_lesser, '<'); setSymbolListener(R.id.action_cardinal, '#'); final Handler uiHandler = new Handler(this); renderer = new ShaderRenderer(shader, uiHandler); shaderView = (ShaderGLView) findViewById(R.id.shader_view); shaderView.setRenderer(renderer); shaderView.setVRModeEnabled(false); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); int textSize = Integer.parseInt(prefs.getString("pref_editor_text_size", "14")); int opacity = Integer.parseInt(prefs.getString("pref_editor_opacity", "127")); editor = (ShaderEditor) findViewById(R.id.editor); editor.setTextSize(textSize); editor.setBackgroundColor(opacity << 24); editor.setHorizontallyScrolling(true); editor.setHorizontalScrollBarEnabled(true); editor.setText(shader.getText()); ScrollView scroll = (ScrollView) findViewById(R.id.scroll); editor.setScrollView(scroll); compileRT = prefs.getBoolean("pref_compile_rt", true); }
From source file:com.grottworkshop.gwsindiaink.TypefaceHelper.java
/** * Set the typeface for the toast view./* w w w.ja va 2 s . c o m*/ * @param toast toast. * @param typefaceName typeface name. * @param style the typeface style. * @return toast that the typeface is injected. */ public Toast setTypeface(Toast toast, String typefaceName, int style) { setTypeface((ViewGroup) toast.getView(), typefaceName, style); return toast; }
From source file:hku.fyp14017.blencode.ui.fragment.ScriptFragment.java
public void updateAdapterAfterAddNewBrick(Brick brickToBeAdded) { int firstVisibleBrick = listView.getFirstVisiblePosition(); int lastVisibleBrick = listView.getLastVisiblePosition(); int position = ((1 + lastVisibleBrick - firstVisibleBrick) / 2); position += firstVisibleBrick;/*from w w w . j a v a 2 s . c o m*/ //TODO: allow recursive userbricks if its possible if (adapter.getUserBrick() != null && brickToBeAdded instanceof UserBrick) {// && ((UserBrick) brickToBeAdded).getDefinitionBrick().equals(ProjectManager.getInstance().getCurrentUserBrick().getDefinitionBrick())) { Toast toast = null; if (toast == null || toast.getView().getWindowVisibility() != View.VISIBLE) { toast = Toast.makeText(getActivity().getApplicationContext(), hku.fyp14017.blencode.R.string.recursive_user_brick_forbidden, Toast.LENGTH_LONG); } else { toast.setText(hku.fyp14017.blencode.R.string.recursive_user_brick_forbidden); } toast.show(); } else { adapter.addNewBrick(position, brickToBeAdded, true); adapter.notifyDataSetChanged(); } }
From source file:biz.incomsystems.fwknop2.ConfigDetailFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // This handles the qrcode results if (requestCode == 0) { if (resultCode == Activity.RESULT_OK) { String contents = data.getStringExtra("SCAN_RESULT"); for (String stanzas : contents.split(" ")) { String[] tmp = stanzas.split(":"); if (tmp[0].equalsIgnoreCase("KEY_BASE64")) { txt_KEY.setText(tmp[1]); chkb64key.setChecked(true); } else if (tmp[0].equalsIgnoreCase("KEY")) { txt_KEY.setText(tmp[1]); chkb64key.setChecked(false); } else if (tmp[0].equalsIgnoreCase("HMAC_KEY_BASE64")) { txt_HMAC.setText(tmp[1]); chkb64hmac.setChecked(true); } else if (tmp[0].equalsIgnoreCase("HMAC_KEY")) { txt_HMAC.setText(tmp[1]); chkb64hmac.setChecked(false); }//from w ww. ja va 2 s .c o m } // end for loop } if (resultCode == Activity.RESULT_CANCELED) { //handle cancel Context context = getActivity(); CharSequence text = " QR Code Canceled"; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER, 0, 0); LinearLayout toastLayout = (LinearLayout) toast.getView(); TextView toastTV = (TextView) toastLayout.getChildAt(0); toastTV.setTextSize(30); toast.show(); } } }
From source file:com.ohso.omgubuntu.BaseFragment.java
@Override public void articlesError() { onRefreshComplete();//from w w w . jav a2 s.c om Log.e("OMG!", "FEED ERROR!"); // Need to make sure fragment still attached to activity, lest we get an IllegalStateException when toasting if (this.isAdded()) { Toast error = Toast.makeText(getActivity(), getResources().getString(R.string.refresh_error), Toast.LENGTH_SHORT); try { ((TextView) ((LinearLayout) error.getView()).getChildAt(0)).setGravity(Gravity.CENTER); } catch (ClassCastException e) { e.printStackTrace(); } error.show(); } }