List of usage examples for android.widget Toast show
public void show()
From source file:org.smilec.smile.student.CourseList.java
public void showToast(String msg) { 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(msg);/*ww w .j a v a 2s . c om*/ Toast toast = new Toast(getApplicationContext()); if (smile.face != null) text.setTypeface(smile.face); text.setText(msg); toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 100); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); }
From source file:com.ezac.gliderlogs.FlightOverviewActivity.java
private void makeToast(String msg, int mode) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(R.drawable.ic_launcher); TextView text = (TextView) layout.findViewById(R.id.text); text.setText(msg);//ww w . j ava 2s . c o m Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); if (mode == 1) { text.setTextColor(Color.WHITE); toast.getView().setBackgroundColor(Color.RED); toast.setDuration(Toast.LENGTH_LONG); } if (mode == 2) { text.setTextColor(Color.WHITE); toast.getView().setBackgroundColor(Color.GREEN); } toast.show(); }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
/** * Creates a toast with the specified message. * * @param message//ww w.j ava 2 s .c o m */ private void showCustomToast(String message, int duration) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.toast_view, null); // set the text in the view TextView tv = (TextView) view.findViewById(R.id.message); tv.setText(message); Toast t = new Toast(this); t.setView(view); t.setDuration(duration); t.setGravity(Gravity.CENTER, 0, 0); t.show(); }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent serverIntent = null;// ww w. j a va 2 s . co m Toast toast = Toast.makeText(LogCabinMainActivity.this, "", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); switch (item.getItemId()) { case R.id.secure_connect_scan:// // Launch the DeviceListActivity to see devices and do scan serverIntent = new Intent(this, DeviceListActivity.class); startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_SECURE); return true; case R.id.insecure_connect_scan:// // Launch the DeviceListActivity to see devices and do scan serverIntent = new Intent(this, DeviceListActivity.class); startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_INSECURE); return true; case R.id.app_developer: toastDisplay(LogCabinMainActivity.this, ": \n\nQQ:1120341494\n:dongleixiaxue314\n :http://www.devwang.com", Gravity.CENTER, R.drawable.hutview, Toast.LENGTH_SHORT); return true; case R.id.app_cmd_what: case R.id.app_voice_what: toast.setText( "\n\n\n\n..."); toast.show(); return true; case R.id.app_college: toast.setText(R.string.str_college); toast.show(); return true; case R.id.app_web_url: toastDisplay(LogCabinMainActivity.this, getString(R.string.http_devwang_sinaapp_com_logcabin_logcabin_web_php), Gravity.CENTER, 0, Toast.LENGTH_SHORT); return true; case R.id.app_update: android.app.AlertDialog.Builder dialog = new AlertDialog.Builder(LogCabinMainActivity.this); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialogview_appupdate, null); dialog.setView(layout); appUpdateEditText = (EditText) layout.findViewById(R.id.et_appupdate); dialog.setPositiveButton(R.string.str_app_update_sure, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String appUpdateEditTextString = appUpdateEditText.getText().toString(); if ("devwang".equals(appUpdateEditTextString.toString())) { AppUpdate = true; Toast.makeText(getApplicationContext(), R.string.str_app_update_pass_toast, Toast.LENGTH_SHORT).show(); } } }); dialog.show(); return true; } return false; }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void showErrorMessage(final Context context, final CharSequence message, final boolean long_message) { if (context == null) return;/* w w w.j ava2s. c o m*/ if (context instanceof Activity) { final Crouton crouton = Crouton.makeText((Activity) context, message, CroutonStyle.ALERT); final CroutonConfiguration.Builder cb = new CroutonConfiguration.Builder(); cb.setDuration(long_message ? CroutonConfiguration.DURATION_LONG : CroutonConfiguration.DURATION_SHORT); crouton.setConfiguration(cb.build()); crouton.show(); } else { final Toast toast = Toast.makeText(context, message, long_message ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT); toast.show(); } }
From source file:cm.aptoide.pt.MainActivity.java
protected void latestClick(final String apkid) { new Thread(new Runnable() { @Override//from ww w .j a va 2s . com public void run() { final long id = db.getApkId(apkid, store_id); System.out.println("Getting Latest id" + id); if (id != -1) { runOnUiThread(new Runnable() { @Override public void run() { Intent i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("top", false); i.putExtra("category", Category.INFOXML.ordinal()); startActivity(i); } }); } else { runOnUiThread(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.error_latest_apk), Toast.LENGTH_SHORT); toast.show(); } }); } } }).start(); }
From source file:cm.aptoide.pt.MainActivity.java
protected void addStore(String uri_str, String username, String password) { if (uri_str.contains("http//")) { uri_str = uri_str.replaceFirst("http//", "http://"); }// w w w.j ava 2 s. c o m if (uri_str.length() != 0 && uri_str.charAt(uri_str.length() - 1) != '/') { uri_str = uri_str + '/'; Log.d("Aptoide-ManageRepo", "repo uri: " + uri_str); } if (!uri_str.startsWith("http://")) { uri_str = "http://" + uri_str; Log.d("Aptoide-ManageRepo", "repo uri: " + uri_str); } if (username != null && username.contains("@")) { try { password = Algorithms.computeSHA1sum(password); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } NetworkUtils utils = new NetworkUtils(); final int response = utils.checkServerConnection(uri_str, username, password); final String uri = uri_str; switch (response) { case 0: service.addStore(db, uri, username, password); break; case 401: runOnUiThread(new Runnable() { @Override public void run() { showAddStoreCredentialsDialog(uri); } }); break; case 404: runOnUiThread(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.verify_store), Toast.LENGTH_SHORT); toast.show(); showAddStoreDialog(); } }); break; case -1: runOnUiThread(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.an_error_check_net), Toast.LENGTH_SHORT); toast.show(); showAddStoreDialog(); } }); break; default: runOnUiThread(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.error_occured) + " " + response, Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 30); toast.show(); showAddStoreDialog(); } }); break; } }
From source file:cm.aptoide.pt.MainActivity.java
@Override public boolean onContextItemSelected(final MenuItem item) { final ProgressDialog pd; switch (item.getItemId()) { case 0://w w w. jav a 2 s . c om pd = new ProgressDialog(mContext); pd.setMessage(getString(R.string.please_wait)); pd.show(); pd.setCancelable(false); new Thread(new Runnable() { private boolean result = false; @Override public void run() { try { result = service.deleteStore(db, ((AdapterContextMenuInfo) item.getMenuInfo()).id); } catch (Exception e) { e.printStackTrace(); } finally { runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); if (result) { refreshAvailableList(false); installedLoader.forceLoad(); updatesLoader.forceLoad(); } else { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.error_delete_store), Toast.LENGTH_SHORT); toast.show(); } } }); } } }).start(); break; case 1: pd = new ProgressDialog(mContext); pd.setMessage(getString(R.string.please_wait)); pd.show(); pd.setCancelable(false); new Thread(new Runnable() { @Override public void run() { try { service.parseServer(db, db.getServer(((AdapterContextMenuInfo) item.getMenuInfo()).id, false)); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); refreshAvailableList(false); } }); } } }).start(); break; } return super.onContextItemSelected(item); }
From source file:cm.aptoide.pt.MainActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { SimpleCursorLoader a = null;/*from w w w.j a v a 2s .c o m*/ switch (id) { case AVAILABLE_LOADER: a = new SimpleCursorLoader(mContext) { @Override public Cursor loadInBackground() { switch (depth) { case STORES: return db.getStores(joinStores_boolean); case CATEGORY1: return db.getCategory1(store_id, joinStores_boolean, !PreferenceManager .getDefaultSharedPreferences(mContext).getBoolean("orderByCategory", true)); case CATEGORY2: return db.getCategory2(category_id, store_id, joinStores_boolean); case ALLAPPLICATIONS: case APPLICATIONS: return db.getApps(category2_id, store_id, joinStores_boolean, order, !PreferenceManager .getDefaultSharedPreferences(mContext).getBoolean("orderByCategory", true)); case TOPAPPS: return db.getTopApps(store_id, joinStores_boolean); case LATESTAPPS: return db.getLatestApps(store_id, joinStores_boolean); case LATEST_LIKES: return new LatestLikesComments(store_id, db, mContext).getLikes(); case LATEST_COMMENTS: return new LatestLikesComments(store_id, db, mContext).getComments(); case RECOMMENDED: final Cursor c = db.getUserBasedApk(store_id, joinStores_boolean); runOnUiThread(new Runnable() { @Override public void run() { if (c.getCount() == 0) { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.no_recommended_toast), Toast.LENGTH_SHORT); toast.show(); } } }); return c; default: return null; } } }; return a; case INSTALLED_LOADER: a = new SimpleCursorLoader(mContext) { @Override public Cursor loadInBackground() { return db.getInstalledApps(order); } }; return a; case UPDATES_LOADER: a = new SimpleCursorLoader(mContext) { @Override public Cursor loadInBackground() { return db.getUpdates(order); } }; return a; default: break; } return null; }
From source file:cm.aptoide.pt.MainActivity.java
private void loadUi() { setContentView(R.layout.activity_aptoide); TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.indicator); pager = (ViewPager) findViewById(R.id.viewpager); if (!ApplicationAptoide.MULTIPLESTORES) { depth = ListDepth.CATEGORY1;/*from w w w .ja v a 2 s .co m*/ store_id = 1; } updateView.findViewById(R.id.update_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { updateAll(); } }); availableListView.setFastScrollEnabled(true); availableListView.addHeaderView(breadcrumbs, null, false); registerForContextMenu(updatesListView); updatesListView.setLongClickable(true); availableView.findViewById(R.id.refresh_view_layout).findViewById(R.id.refresh_view) .setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { refreshClick = true; availableView.findViewById(R.id.refresh_view_layout).setVisibility(View.GONE); refreshAvailableList(false); } }); joinStores.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { joinStores_boolean = isChecked; // if (isChecked) { // addBreadCrumb("All Stores", depth); // } else { // breadcrumbs.removeAllViews(); // } refreshAvailableList(true); } }); bindService(serviceDownloadManagerIntent, serviceManagerConnection, BIND_AUTO_CREATE); pb.setText(R.string.add_store_button_below); addStoreButton.setOnClickListener(addStoreListener); if (!ApplicationAptoide.MULTIPLESTORES) { addStoreButton.setVisibility(View.GONE); } availableListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i; View v = availableListView.getChildAt(0); scrollMemory.put(depth, new ListViewPosition((v == null) ? 0 : v.getTop(), availableListView.getFirstVisiblePosition())); switch (depth) { case STORES: depth = ListDepth.CATEGORY1; store_id = id; break; case CATEGORY1: String category = ((Cursor) parent.getItemAtPosition(position)).getString(1); if (category.equals("Top Apps")) { depth = ListDepth.TOPAPPS; } else if (category.equals("Latest Apps")) { depth = ListDepth.LATESTAPPS; } else if (id == LATEST_LIKES) { depth = ListDepth.LATEST_LIKES; } else if (id == LATEST_COMMENTS) { depth = ListDepth.LATEST_COMMENTS; } else if (id == -3) { if (!Login.isLoggedIn(mContext)) { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.you_need_to_login_toast), Toast.LENGTH_SHORT); toast.show(); return; } else { depth = ListDepth.RECOMMENDED; } } else if (id == -4) { depth = ListDepth.ALLAPPLICATIONS; } else if (id == -10) { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.store_beginning_to_load), Toast.LENGTH_SHORT); toast.show(); return; } else { depth = ListDepth.CATEGORY2; } category_id = id; break; case CATEGORY2: depth = ListDepth.APPLICATIONS; category2_id = id; break; case TOPAPPS: i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("top", true); i.putExtra("category", Category.TOP.ordinal()); startActivity(i); return; case LATESTAPPS: i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("top", true); i.putExtra("category", Category.LATEST.ordinal()); startActivity(i); return; case APPLICATIONS: case ALLAPPLICATIONS: case RECOMMENDED: i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("top", false); i.putExtra("category", Category.INFOXML.ordinal()); startActivity(i); return; case LATEST_COMMENTS: case LATEST_LIKES: String apkid = ((Cursor) parent.getItemAtPosition(position)).getString(1); latestClick(apkid); return; default: return; } addBreadCrumb(((Cursor) parent.getItemAtPosition(position)).getString(1), depth); refreshAvailableList(true); } }); installedView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) { Intent i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("installed", true); i.putExtra("category", Category.INFOXML.ordinal()); startActivity(i); } }); ImageView brandIv = (ImageView) findViewById(R.id.brand); if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("jblow")) { brandIv.setImageResource(R.drawable.brand_jblow); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("magalhaes")) { brandIv.setImageResource(R.drawable.brand_magalhaes); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("timwe")) { brandIv.setImageResource(R.drawable.brand_timwe); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("digitallydifferent")) { brandIv.setImageResource(R.drawable.brand_digitallydifferent); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("eocean")) { brandIv.setImageResource(R.drawable.brand_eocean); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("educomp")) { brandIv.setImageResource(R.drawable.brand_educomp); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("peoplenet")) { brandIv.setImageResource(R.drawable.brand_peoplenet); } else if (ApplicationAptoide.BRAND != null) { brandIv.setImageResource(getBrandDrawableResource()); } else { brandIv.setImageResource(R.drawable.brand_aptoide); } findViewById(R.id.btsearch).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onSearchRequested(); } }); updatesListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) { Intent i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("updates", true); i.putExtra("category", Category.INFOXML.ordinal()); startActivity(i); } }); // LoaderManager.enableDebugLogging(true); availableLoader = getSupportLoaderManager().initLoader(AVAILABLE_LOADER, null, this); ArrayList<View> views = new ArrayList<View>(); views.add(featuredView); views.add(availableView); views.add(installedView); views.add(updateView); pager.setAdapter(new ViewPagerAdapter(mContext, views)); indicator.setViewPager(pager); refreshAvailableList(true); if (!ApplicationAptoide.MULTIPLESTORES) { addBreadCrumb(getString(R.string.store), ListDepth.CATEGORY1); } else { addBreadCrumb(getString(R.string.stores), ListDepth.STORES); } if (!ApplicationAptoide.MATURECONTENTSWITCH) { featuredView.findViewById(R.id.toggleButton1).setVisibility(View.GONE); featuredView.findViewById(R.id.adultcontent_label).setVisibility(View.GONE); } }