List of usage examples for android.widget TextView setCompoundDrawablesWithIntrinsicBounds
@android.view.RemotableViewMethod public void setCompoundDrawablesWithIntrinsicBounds(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom)
From source file:com.nadmm.airports.wx.MetarFragment.java
protected void showWindInfo(LinearLayout layout, Metar metar) { View row = addRow(layout, getWindsDescription(metar)); TextView tv = (TextView) row.findViewById(R.id.item_label); if (metar.windDirDegrees > 0) { float declination = GeoUtils.getMagneticDeclination(mLocation); Drawable wind = WxUtils.getWindBarbDrawable(tv.getContext(), metar, declination); tv.setCompoundDrawablesWithIntrinsicBounds(wind, null, null, null); tv.setCompoundDrawablePadding(UiUtils.convertDpToPx(getActivity(), 6)); }//from ww w . j av a2 s. c om if (metar.windGustKnots < Integer.MAX_VALUE) { double gustFactor = metar.windGustKnots - metar.windSpeedKnots; addRow(layout, String.format("Add %d knots to your normal approach speed", Math.round(gustFactor / 2))); } if (metar.wshft) { StringBuilder sb = new StringBuilder(); sb.append("Wind shift of 45\u00B0 or more detected during past hour"); if (metar.fropa) { sb.append(" due to frontal passage"); } addRow(layout, sb.toString()); } }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout InActivateColorize(LinearLayout ll, String text, Drawable dr) { // text/*from w ww.ja v a 2 s . c om*/ TextView v = (TextView) ll.findViewWithTag("tv"); v.setText(text); v.setTextSize(10); v.setTextColor(Color.GRAY); v.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); dr.setColorFilter(0xFF888888, android.graphics.PorterDuff.Mode.SRC_ATOP); v.setCompoundDrawablesWithIntrinsicBounds(null, dr, null, null); v.setPadding(0, 5, 0, 2); v.setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_tabs)); // hbar View hbar = ll.findViewWithTag("hbar"); hbar.setBackgroundDrawable(null); hbar.setBackgroundColor(resources.getColor(R.color.graylight)); return ll; }
From source file:com.yahala.ui.GroupCreateFinalActivity.java
@Override public void applySelfActionBar() { if (parentActivity == null) { return;// www . j av a2s .c o m } ActionBar actionBar = parentActivity.getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowCustomEnabled(false); actionBar.setCustomView(null); actionBar.setSubtitle(null); actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title); if (title == null) { final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android"); title = (TextView) parentActivity.findViewById(subtitleId); } if (title != null) { title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); title.setCompoundDrawablePadding(0); } }
From source file:de.baumann.hhsmoodle.popup.Popup_todo.java
private void setTodoList() { PreferenceManager.setDefaultValues(Popup_todo.this, R.xml.user_settings, false); final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(Popup_todo.this); NotificationManager nMgr = (NotificationManager) Popup_todo.this .getSystemService(Context.NOTIFICATION_SERVICE); nMgr.cancelAll();//from w w w . j a v a 2 s .c o m //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "todo_title", "todo_content", "todo_creation" }; final String search = sharedPref.getString("filter_todo_subject", ""); final Cursor row = db.fetchDataByFilter(search, "todo_title"); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_todo.this, layoutstyle, row, column, xml_id, 0) { @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (todo_icon) { case "3": iv_icon.setImageResource(R.drawable.circle_green); break; case "2": iv_icon.setImageResource(R.drawable.circle_yellow); break; case "1": iv_icon.setImageResource(R.drawable.circle_red); break; } switch (todo_attachment) { case "true": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle_red); int n = Integer.valueOf(_id); android.content.Intent iMain = new android.content.Intent(); iMain.setAction("shortcutToDo"); iMain.setClassName(Popup_todo.this, "de.baumann.hhsmoodle.activities.Activity_splash"); PendingIntent piMain = PendingIntent.getActivity(Popup_todo.this, n, iMain, 0); NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(Popup_todo.this) .setSmallIcon(R.drawable.school) .setColor(ContextCompat.getColor(Popup_todo.this, R.color.colorPrimary)) .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain); Notification notification = new NotificationCompat.Builder(Popup_todo.this) .setColor(ContextCompat.getColor(Popup_todo.this, R.color.colorPrimary)) .setSmallIcon(R.drawable.school).setContentTitle(todo_title) .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true) .setGroup("HHS_Moodle") .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content)) .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build(); NotificationManager notificationManager = (NotificationManager) Popup_todo.this .getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(n, notification); notificationManager.notify(0, builderSummary.build()); break; } iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final Item[] items = { new Item(getString(R.string.note_priority_0), R.drawable.circle_green), new Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new Item(getString(R.string.note_priority_2), R.drawable.circle_red), }; ListAdapter adapter = new ArrayAdapter<Item>(Popup_todo.this, android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(Popup_todo.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { db.update(Integer.parseInt(_id), todo_title, todo_content, "3", todo_attachment, todo_creation); setTodoList(); } else if (item == 1) { db.update(Integer.parseInt(_id), todo_title, todo_content, "2", todo_attachment, todo_creation); setTodoList(); } else if (item == 2) { db.update(Integer.parseInt(_id), todo_title, todo_content, "1", todo_attachment, todo_creation); setTodoList(); } } }).show(); } }); iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { switch (todo_attachment) { case "true": db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "", todo_creation); setTodoList(); break; default: db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "true", todo_creation); setTodoList(); break; } } }); return v; } }; lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); sharedPref.edit().putString("toDo_title", todo_title).apply(); sharedPref.edit().putString("toDo_text", todo_content).apply(); sharedPref.edit().putString("toDo_seqno", _id).apply(); sharedPref.edit().putString("toDo_icon", todo_icon).apply(); sharedPref.edit().putString("toDo_create", todo_creation).apply(); sharedPref.edit().putString("toDo_attachment", todo_attachment).apply(); helper_main.switchToActivity(Popup_todo.this, Activity_todo.class, false); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation")); final CharSequence[] options = { getString(R.string.bookmark_edit_title), getString(R.string.todo_share), getString(R.string.bookmark_createNote), getString(R.string.bookmark_createEvent), getString(R.string.bookmark_remove_bookmark) }; new AlertDialog.Builder(Popup_todo.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.bookmark_edit_title))) { AlertDialog.Builder builder = new AlertDialog.Builder(Popup_todo.this); View dialogView = View.inflate(Popup_todo.this, R.layout.dialog_edit_title, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setHint(R.string.bookmark_edit_title); edit_title.setText(todo_title); builder.setView(dialogView); builder.setTitle(R.string.bookmark_edit_title); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); db.update(Integer.parseInt(_id), inputTag, todo_content, todo_icon, todo_attachment, todo_creation); setTodoList(); Snackbar.make(lv, R.string.bookmark_added, Snackbar.LENGTH_SHORT).show(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(Popup_todo.this, edit_title); } if (options[item].equals(getString(R.string.todo_share))) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, todo_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, todo_content); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.bookmark_createEvent))) { Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); calIntent.putExtra(CalendarContract.Events.TITLE, todo_title); calIntent.putExtra(CalendarContract.Events.DESCRIPTION, todo_content); startActivity(calIntent); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setTodoList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.bookmark_createNote))) { sharedPref.edit().putString("handleTextTitle", todo_title) .putString("handleTextText", todo_content).apply(); helper_main.switchToActivity(Popup_todo.this, Activity_EditNote.class, false); } } }).show(); return true; } }); if (lv.getAdapter().getCount() == 0) { new android.app.AlertDialog.Builder(this) .setMessage(helper_main.textSpannable(getString(R.string.toast_noEntry))) .setPositiveButton(this.getString(R.string.toast_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }).show(); new Handler().postDelayed(new Runnable() { public void run() { finish(); } }, 2000); } }
From source file:de.kodejak.hashr.fragmentHashFromText.java
public void OnButtonCompareClick() { TextView edOutput = (TextView) getView().findViewById(R.id.edOutput); String strOutput = edOutput.getText().toString(); EditText edCompare = (EditText) getView().findViewById(R.id.edCompare); String strCompare = edCompare.getText().toString(); TextView tvMatch = (TextView) getView().findViewById(R.id.tvCompare); if (strOutput.length() < 1 || strCompare.length() < 1) { return;//from www. ja v a 2s . com } if (strOutput.equals(strCompare)) { tvMatch.setText("Match !"); if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { tvMatch.setBackgroundDrawable(getResources().getDrawable(R.drawable.match_ok_bg)); } else { tvMatch.setBackground(getResources().getDrawable(R.drawable.match_ok_bg)); } tvMatch.setTextColor(Color.WHITE); tvMatch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check, 0, 0, 0); } else { tvMatch.setText("No match !"); if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { tvMatch.setBackgroundDrawable(getResources().getDrawable(R.drawable.match_notok_bg)); } else { tvMatch.setBackground(getResources().getDrawable(R.drawable.match_notok_bg)); } tvMatch.setTextColor(Color.WHITE); tvMatch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_cancel, 0, 0, 0); } tvMatch.setVisibility(View.VISIBLE); }
From source file:pl.polak.oversnackbar.OverSnackBar.java
public OverSnackBar addIcon(int resource_id, int size) { final TextView tv = mView.getMessageView(); tv.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(Bitmap.createScaledBitmap( ((BitmapDrawable) (mContext.getResources().getDrawable(resource_id))).getBitmap(), size, size, true)), null, null, null);/*from w w w .j a v a2s . c o m*/ return this; }
From source file:com.secbro.qark.filebrowser.FileBrowserFragment.java
private void createFileListAdapter() { adapter = new ArrayAdapter<Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, fileList) {//from w ww. j a va2 s. c om @Override public View getView(int position, View convertView, ViewGroup parent) { // creates view View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(android.R.id.text1); // put the image on the text view int drawableID = 0; if (fileList.get(position).icon != -1) { // If icon == -1, then directory is empty drawableID = fileList.get(position).icon; } textView.setCompoundDrawablesWithIntrinsicBounds(drawableID, 0, 0, 0); textView.setEllipsize(null); // add margin between image and text (support various screen // densities) // int dp5 = (int) (5 * // getResources().getDisplayMetrics().density + 0.5f); int dp3 = (int) (3 * getResources().getDisplayMetrics().density + 0.5f); // TODO: change next line for empty directory, so text will be // centered textView.setCompoundDrawablePadding(dp3); textView.setBackgroundColor(Color.LTGRAY); return view; }// public View getView(int position, View convertView, ViewGroup };// adapter = new ArrayAdapter<Item>(this, }
From source file:de.baumann.hhsmoodle.popup.Popup_note.java
private void setNotesList() { //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "note_title", "note_content", "note_creation" }; final String search = sharedPref.getString("filter_note_subject", ""); final Cursor row = db.fetchDataByFilter(search, "note_title"); SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_note.this, layoutstyle, row, column, xml_id, 0) {// w w w . j a v a 2 s .com @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (note_icon) { case "3": iv_icon.setImageResource(R.drawable.circle_green); break; case "2": iv_icon.setImageResource(R.drawable.circle_yellow); break; case "1": iv_icon.setImageResource(R.drawable.circle_red); break; } switch (note_attachment) { case "": iv_attachment.setVisibility(View.GONE); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.ic_attachment); break; } File file = new File(note_attachment); if (!file.exists()) { iv_attachment.setVisibility(View.GONE); } iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final Item[] items = { new Item(getString(R.string.note_priority_0), R.drawable.circle_green), new Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new Item(getString(R.string.note_priority_2), R.drawable.circle_red), }; ListAdapter adapter = new ArrayAdapter<Item>(Popup_note.this, android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(Popup_note.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { db.update(Integer.parseInt(_id), note_title, note_content, "3", note_attachment, note_creation); setNotesList(); } else if (item == 1) { db.update(Integer.parseInt(_id), note_title, note_content, "2", note_attachment, note_creation); setNotesList(); } else if (item == 2) { db.update(Integer.parseInt(_id), note_title, note_content, "1", note_attachment, note_creation); setNotesList(); } } }).show(); } }); iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(Popup_note.this, lv, note_attachment); } }); return v; } }; lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); final Button attachment2; final TextView textInput; LayoutInflater inflater = Popup_note.this.getLayoutInflater(); final ViewGroup nullParent = null; final View dialogView = inflater.inflate(R.layout.dialog_note_show, nullParent); final String attName = note_attachment.substring(note_attachment.lastIndexOf("/") + 1); final String att = getString(R.string.app_att) + ": " + attName; attachment2 = (Button) dialogView.findViewById(R.id.button_att); if (attName.equals("")) { attachment2.setVisibility(View.GONE); } else { attachment2.setText(att); } File file2 = new File(note_attachment); if (!file2.exists()) { attachment2.setVisibility(View.GONE); } textInput = (TextView) dialogView.findViewById(R.id.note_text_input); textInput.setText(note_content); Linkify.addLinks(textInput, Linkify.WEB_URLS); attachment2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { helper_main.openAtt(Popup_note.this, lv, note_attachment); } }); final ImageView be = (ImageView) dialogView.findViewById(R.id.imageButtonPri); switch (note_icon) { case "3": be.setImageResource(R.drawable.circle_green); break; case "2": be.setImageResource(R.drawable.circle_yellow); break; case "1": be.setImageResource(R.drawable.circle_red); break; } android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(Popup_note.this) .setTitle(note_title).setView(dialogView) .setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setNegativeButton(R.string.note_edit, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { sharedPref.edit().putString("handleTextTitle", note_title) .putString("handleTextText", note_content) .putString("handleTextIcon", note_icon).putString("handleTextSeqno", _id) .putString("handleTextAttachment", note_attachment) .putString("handleTextCreate", note_creation).apply(); helper_main.switchToActivity(Popup_note.this, Activity_EditNote.class, false); } }); dialog.show(); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String note_title = row2.getString(row2.getColumnIndexOrThrow("note_title")); final String note_content = row2.getString(row2.getColumnIndexOrThrow("note_content")); final String note_icon = row2.getString(row2.getColumnIndexOrThrow("note_icon")); final String note_attachment = row2.getString(row2.getColumnIndexOrThrow("note_attachment")); final String note_creation = row2.getString(row2.getColumnIndexOrThrow("note_creation")); final CharSequence[] options = { getString(R.string.note_edit), getString(R.string.note_share), getString(R.string.todo_menu), getString(R.string.bookmark_createEvent), getString(R.string.note_remove_note) }; new AlertDialog.Builder(Popup_note.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.note_edit))) { sharedPref.edit().putString("handleTextTitle", note_title) .putString("handleTextText", note_content) .putString("handleTextIcon", note_icon) .putString("handleTextSeqno", _id) .putString("handleTextAttachment", note_attachment) .putString("handleTextCreate", note_creation).apply(); helper_main.switchToActivity(Popup_note.this, Activity_EditNote.class, false); } if (options[item].equals(getString(R.string.note_share))) { File attachment = new File(note_attachment); Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, note_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, note_content); if (attachment.exists()) { Uri bmpUri = Uri.fromFile(attachment); sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); } startActivity(Intent.createChooser(sharingIntent, (getString(R.string.note_share_2)))); } if (options[item].equals(getString(R.string.todo_menu))) { Todo_DbAdapter db = new Todo_DbAdapter(Popup_note.this); db.open(); if (db.isExist(note_title)) { Snackbar.make(lv, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG) .show(); } else { db.insert(note_title, note_content, "3", "true", helper_main.createDate()); ViewPager viewPager = (ViewPager) Popup_note.this .findViewById(R.id.viewpager); viewPager.setCurrentItem(2); Popup_note.this.setTitle(R.string.todo_title); dialog.dismiss(); } } if (options[item].equals(getString(R.string.bookmark_createEvent))) { Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); calIntent.putExtra(CalendarContract.Events.TITLE, note_title); calIntent.putExtra(CalendarContract.Events.DESCRIPTION, note_content); startActivity(calIntent); } if (options[item].equals(getString(R.string.note_remove_note))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setNotesList(); } }); snackbar.show(); } } }).show(); return true; } }); if (lv.getAdapter().getCount() == 0) { new android.app.AlertDialog.Builder(this) .setMessage(helper_main.textSpannable(getString(R.string.toast_noEntry))) .setPositiveButton(this.getString(R.string.toast_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }).show(); new Handler().postDelayed(new Runnable() { public void run() { finish(); } }, 2000); } }
From source file:com.yahala.ui.LanguageSelectActivity.java
@Override public void applySelfActionBar() { if (parentActivity == null) { return;/*from w ww. j a va2 s .c om*/ } ActionBar actionBar = parentActivity.getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowCustomEnabled(false); actionBar.setCustomView(null); actionBar.setSubtitle(null); TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title); if (title == null) { final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android"); title = (TextView) parentActivity.findViewById(subtitleId); } if (title != null) { title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); title.setCompoundDrawablePadding(0); } actionBar.setTitle(LocaleController.getString("Language", R.string.Language)); ((LaunchActivity) parentActivity).fixBackButton(); }
From source file:piuk.blockchain.android.ui.AbstractWalletActivity.java
public final void toast(final int textResId, final int imageResId, final int duration, final Object... formatArgs) { final View view = getLayoutInflater().inflate(R.layout.transient_notification, null); TextView tv = (TextView) view.findViewById(R.id.transient_notification_text); tv.setText(getString(textResId, formatArgs)); tv.setCompoundDrawablesWithIntrinsicBounds(imageResId, 0, 0, 0); final Toast toast = new Toast(this); toast.setView(view);/*from w w w .ja va 2s .com*/ toast.setDuration(duration); toast.show(); }