List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.bt.download.android.gui.adapters.SearchResultListAdapter.java
protected void populateFilePart(View view, FileSearchResult sr) { ImageView fileTypeIcon = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon); fileTypeIcon.setImageResource(getFileTypeIconId()); TextView adIndicator = findView(view, R.id.view_bittorrent_search_result_list_item_ad_indicator); adIndicator.setVisibility(View.GONE); TextView title = findView(view, R.id.view_bittorrent_search_result_list_item_title); title.setText(sr.getDisplayName());//ww w. ja va2s .c o m // if marked as downloading // title.setTextColor(GlobalConstants.COLOR_DARK_BLUE); TextView fileSize = findView(view, R.id.view_bittorrent_search_result_list_item_file_size); if (sr.getSize() > 0) { fileSize.setText(UIUtils.getBytesInHuman(sr.getSize())); } else { fileSize.setText(""); } TextView extra = findView(view, R.id.view_bittorrent_search_result_list_item_text_extra); extra.setText(FilenameUtils.getExtension(sr.getFilename())); TextView seeds = findView(view, R.id.view_bittorrent_search_result_list_item_text_seeds); seeds.setText(""); String license = sr.getLicense().equals(License.UNKNOWN) ? "" : " - " + sr.getLicense(); TextView sourceLink = findView(view, R.id.view_bittorrent_search_result_list_item_text_source); sourceLink.setText(sr.getSource() + license); // TODO: ask for design sourceLink.setTag(sr.getDetailsUrl()); sourceLink.setPaintFlags(sourceLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); sourceLink.setOnClickListener(linkListener); }
From source file:com.hippo.widget.Snackbar.java
@NonNull public Snackbar setAction(CharSequence text, final View.OnClickListener listener) { TextView tv = mView.getActionView(); if ((TextUtils.isEmpty(text)) || (listener == null)) { tv.setVisibility(View.GONE); tv.setOnClickListener(null); } else {/*from www . ja v a 2 s .c o m*/ tv.setVisibility(View.VISIBLE); tv.setText(text); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { listener.onClick(view); dispatchDismiss(Callback.DISMISS_EVENT_ACTION); } }); } return this; }
From source file:de.ktran.anno1404warenrechner.views.PopulationNumberDialog.java
@SuppressLint({ "SetTextI18n", "InflateParams" }) @NonNull/*from www . ja va 2s . co m*/ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { TypedArray attributes = getContext().obtainStyledAttributes(theme, R.styleable.SimpleNumberPicker); LayoutInflater inflater = getActivity().getLayoutInflater(); View view; if (populationType instanceof PopulationType) { view = inflater.inflate(R.layout.number_picker, null); } else { view = inflater.inflate(R.layout.house_number_picker, null); seekBar = (SeekBar) view.findViewById(R.id.houseNumberPickerPopLimit); advancementText = (TextView) view.findViewById(R.id.houseNumberPickerPopLimitDesc); if (seekBar == null || advancementText == null) throw new IllegalStateException("Not all views could be found."); if (populationType == PopulationType.Civilization.OCCIDENTAL) { seekBar.setMax(3); seekBar.setProgress(3); setAdvancementText(3, PopulationType.Civilization.OCCIDENTAL); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { setAdvancementText(progress, PopulationType.Civilization.OCCIDENTAL); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } else if (populationType == PopulationType.Civilization.ORIENTAL) { seekBar.setMax(1); seekBar.setProgress(1); setAdvancementText(1, PopulationType.Civilization.ORIENTAL); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { setAdvancementText(progress, PopulationType.Civilization.ORIENTAL); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } } // Init number int color = attributes.getColor(R.styleable.SimpleNumberPicker_snpKeyColor, ContextCompat.getColor(getContext(), android.R.color.secondary_text_light)); numberTextView = (TextView) view.findViewById(R.id.tv_hex_number); numberTextView.setTextColor(color); if (null != savedInstanceState && savedInstanceState.containsKey(ARG_SAVED_VALUE)) numberTextView.setText(savedInstanceState.getString(ARG_SAVED_VALUE)); else if (forceHouse) numberTextView.setText(""); // Init backspace color = attributes.getColor(R.styleable.SimpleNumberPicker_snpBackspaceColor, ContextCompat.getColor(getContext(), android.R.color.secondary_text_light)); backspaceButton = (ImageButton) view.findViewById(R.id.key_backspace); backspaceButton.setImageDrawable( ThemeUtil.makeSelector(getContext(), R.drawable.snp_ic_backspace_black_24dp, color)); backspaceButton.setOnClickListener(v -> { if (numberTextView.getText().length() == 1 && forceHouse) return; CharSequence number = numberTextView.getText().subSequence(0, numberTextView.getText().length() - 1); if (1 == number.length() && '-' == number.charAt(0)) number = ""; numberTextView.setText(number); onNumberChanged(); }); backspaceButton.setOnLongClickListener(v -> { numberTextView.setText(""); onNumberChanged(); return true; }); // Create dialog dialog = new AlertDialog.Builder(getContext(), theme).setView(view) .setPositiveButton(android.R.string.ok, (dialog12, which) -> { String result = numberTextView.getText().toString(); if (result.isEmpty()) result = "0"; result = result.replace(',', '.'); result = result.replace("", "-"); if (result.equals("-")) result = "0"; final int number = Integer.parseInt(result); handleDialogFinish(number); dismiss(); }).setNegativeButton(android.R.string.cancel, (dialog1, which) -> dismiss()).create(); // Init dialog color = attributes.getColor(R.styleable.SimpleNumberPicker_snpDialogBackground, ContextCompat.getColor(getContext(), android.R.color.white)); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(color)); } // Init keys View.OnClickListener listener = v -> { int key = (int) v.getTag(); String id = numberTextView.getText() + Integer.toString(key); numberTextView.setText(id); onNumberChanged(); }; color = attributes.getColor(R.styleable.SimpleNumberPicker_snpKeyColor, ThemeUtil.getThemeAccentColor(getContext())); TypedArray ids = getResources().obtainTypedArray(R.array.snp_key_ids); for (int i = 0; i < NB_KEYS; i++) { TextView key = (TextView) view.findViewById(ids.getResourceId(i, -1)); key.setTag(i); key.setOnClickListener(listener); key.setTextColor(color); } // Init sign TextView sign = (TextView) view.findViewById(R.id.key_house); if (!this.forceHouse) { sign.setTextColor(color); sign.setOnClickListener(v -> { String number = numberTextView.getText().toString(); if (number.startsWith("")) { numberTextView.setText(number.substring(1)); } else { numberTextView.setText("" + number); } onNumberChanged(); }); } else { sign.setVisibility(View.GONE); } ids.recycle(); attributes.recycle(); return dialog; }
From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripView.java
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = (ViewGroup) findViewById(R.id.suggestions_strip); mVoiceKey = (ImageButton) findViewById(R.id.suggestions_strip_voice_key); mAddToDictionaryStrip = (ViewGroup) findViewById(R.id.add_to_dictionary_strip); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mAddToDictionaryStrip, mImportantNoticeStrip);/*w ww . j a v a2 s. c o m*/ for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word); final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); mDebugInfoViews.add(info); } mLayoutHelper = new SuggestionStripLayoutHelper(context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = (MoreSuggestionsView) mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res .getDimensionPixelOffset(R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector(context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey); keyboardAttr.recycle(); mVoiceKey.setImageDrawable(iconVoice); mVoiceKey.setOnClickListener(this); }
From source file:com.gh4a.activities.IssueCreateActivity.java
public void fillLabels(List<Label> labels) { Gh4Application app = Gh4Application.get(this); LinearLayout labelLayout = (LinearLayout) findViewById(R.id.ll_labels); for (final Label label : labels) { final View rowView = getLayoutInflater().inflate(R.layout.row_issue_create_label, null); View viewColor = rowView.findViewById(R.id.view_color); viewColor.setBackgroundColor(Color.parseColor("#" + label.getColor())); final TextView tvLabel = (TextView) rowView.findViewById(R.id.tv_title); tvLabel.setTypeface(app.condensed); tvLabel.setText(label.getName()); tvLabel.setOnClickListener(this); tvLabel.setTag(label);//from w ww .j ava 2s .c o m if (isInEditMode()) { handleLabelClick(tvLabel, label, mSelectedLabels.contains(label)); } labelLayout.addView(rowView); } }
From source file:com.oasis.sdk.activity.OasisSdkPayEpinActivity.java
private void showResultDialog(final String res) { final AlertDialog d = new AlertDialog.Builder(this).create(); d.show();/*ww w. jav a2 s . co m*/ d.setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_common_dialog_notitle")); d.setCanceledOnTouchOutside(false); TextView tv_content = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_content")); String content = getResources().getString(BaseUtils.getResourceValue("string", TextUtils.isEmpty(res) ? "oasisgames_sdk_epin_notice_3" : "oasisgames_sdk_epin_notice_4")); content = content.replace("DIAMOND", res); tv_content.setText(content); TextView tv_sure = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_sure")); tv_sure.setText( getResources().getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_common_btn_sure"))); tv_sure.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (!TextUtils.isEmpty(res)) et_code.setText(""); d.dismiss(); } }); TextView tv_cancle = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_cancle")); tv_cancle.setVisibility(View.GONE); TextView tv_text = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_text")); tv_text.setVisibility(View.GONE); }
From source file:com.kunze.androidlocaltodo.TaskActivityFragment.java
private void InitializeView(final View rootView) { final View activityView = rootView; TextWatcher textWatcher = new TextWatcher() { @Override/* w w w .j a v a 2 s .c o m*/ public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { TaskChanged(activityView); } }; final EditText nameEdit = (EditText) rootView.findViewById(R.id.task_name_edit); final TextView nameStatic = (TextView) rootView.findViewById(R.id.task_name_static); nameStatic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { nameEdit.setVisibility(View.VISIBLE); nameStatic.setVisibility(View.INVISIBLE); } }); nameEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { nameEdit.setVisibility(View.INVISIBLE); nameStatic.setVisibility(View.VISIBLE); } } }); nameEdit.addTextChangedListener(textWatcher); final TextView descriptionEdit = (TextView) rootView.findViewById(R.id.task_description_edit); descriptionEdit.addTextChangedListener(textWatcher); final TextView dueDateView = (TextView) rootView.findViewById(R.id.due_date_text); final DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.due_date_calendar); datePicker.init(0, 0, 0, new DatePicker.OnDateChangedListener() { @Override public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Calendar calendar = Calendar.getInstance(); calendar.set(year, monthOfYear, dayOfMonth, 0, 0, 0); SetFriendlyDueDateText(dueDateView, calendar); TaskChanged(activityView); } }); Button todayButton = (Button) rootView.findViewById(R.id.today_button); todayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar now = Calendar.getInstance(); datePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)); SetFriendlyDueDateText(dueDateView, now); } }); Button plusDayButton = (Button) rootView.findViewById(R.id.plus_day_button); plusDayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar calendar = Calendar.getInstance(); calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth()); calendar.add(Calendar.DATE, 1); datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); SetFriendlyDueDateText(dueDateView, calendar); } }); Button thisWeekendButton = (Button) rootView.findViewById(R.id.this_weekend_button); thisWeekendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar weekend = Calendar.getInstance(); while (weekend.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { weekend.add(Calendar.DATE, 1); } datePicker.updateDate(weekend.get(Calendar.YEAR), weekend.get(Calendar.MONTH), weekend.get(Calendar.DAY_OF_MONTH)); SetFriendlyDueDateText(dueDateView, weekend); } }); Button plusWeekButton = (Button) rootView.findViewById(R.id.plus_week_button); plusWeekButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar calendar = Calendar.getInstance(); calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth()); calendar.add(Calendar.DATE, 7); datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); SetFriendlyDueDateText(dueDateView, calendar); } }); final CheckBox repeatCheck = (CheckBox) rootView.findViewById(R.id.repeat); repeatCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { View dialog = (View) buttonView.getParent(); SetRepeatVisibility(dialog, isChecked); TaskChanged(activityView); } }); final EditText repeatTimeEdit = (EditText) rootView.findViewById(R.id.repeat_time); repeatTimeEdit.addTextChangedListener(textWatcher); final Spinner repeatUnitSpinner = (Spinner) rootView.findViewById(R.id.repeat_unit); String[] repeatUnits = { "Days", "Weeks", "Months", "Years" }; repeatUnitSpinner.setAdapter( new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, repeatUnits)); repeatUnitSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (mRow != -1 && mRow != id) { TaskChanged(activityView); } mRow = id; } @Override public void onNothingSelected(AdapterView<?> arg0) { TaskChanged(activityView); } private long mRow = -1; }); final RadioButton repeatFromComplete = (RadioButton) rootView.findViewById(R.id.repeat_from_complete); final RadioButton repeatFromDue = (RadioButton) rootView.findViewById(R.id.repeat_from_due); Button revertButton = (Button) rootView.findViewById(R.id.revert_button); Button acceptButton = (Button) rootView.findViewById(R.id.accept_button); final Button doneButton = (Button) rootView.findViewById(R.id.done_button); Button deleteButton = (Button) rootView.findViewById(R.id.delete_button); revertButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNewTask = new Task(mOriginalTask); mProgrammaticChange = true; InitializeViewFields(activityView, mOriginalTask); mProgrammaticChange = false; TaskReverted(activityView); } }); doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(doneButton.getContext()); builder.setTitle("Done?"); builder.setMessage("Mark task \"" + mNewTask.mName + "\" as done?"); builder.setNegativeButton("No", null); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mNewTask.Done(); TaskDatabase db = new TaskDatabase(getActivity()); db.SaveTask(mNewTask); InitializeViewFields(rootView, mNewTask); } }); builder.show(); } }); }
From source file:com.angelhack.person2person.AbstractGetNameTask.java
@Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); try {/* w w w .ja v a 2 s . c o m*/ System.out.println("On Home Page***" + AbstractGetNameTask.GOOGLE_USER_DATA); JSONObject profileData = new JSONObject(AbstractGetNameTask.GOOGLE_USER_DATA); if (profileData.has("picture")) { SocialMedia_New.userImageUrl = profileData.getString("picture"); } if (profileData.has("name")) { SocialMedia_New.textName = profileData.getString("name"); // SocialMedia_New.textViewName.setText(SocialMedia_New.textName); } dialog.dismiss(); final Dialog alert_dialog = new Dialog(mActivity); alert_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); alert_dialog.setContentView(R.layout.dialog_custom); TextView content = (TextView) alert_dialog.findViewById(R.id.content_tv_id); TextView ok = (TextView) alert_dialog.findViewById(R.id.ok_tv_id); profile = (ImageView) alert_dialog.findViewById(R.id.image_id); new GetImageFromUrl().execute(SocialMedia_New.userImageUrl); content.setText(" Welcome " + SocialMedia_New.textName); ok.setText("Stay Connect with Us..!"); ok.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(mActivity, Home_Activity.class); mActivity.startActivity(intent); mActivity.overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); mActivity.finish(); } }); alert_dialog.show(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.app.blockydemo.content.bricks.SetVariableBrick.java
@Override public View getView(final Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; }//w w w.j ava 2 s.c om if (view == null) { alphaValue = 255; } view = View.inflate(context, R.layout.brick_set_variable, null); view = getViewWithAlpha(alphaValue); setCheckboxView(R.id.brick_set_variable_checkbox); final Brick brickInstance = this; checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checked = isChecked; adapter.handleCheck(brickInstance, isChecked); } }); TextView prototypeText = (TextView) view.findViewById(R.id.brick_set_variable_prototype_view); TextView textField = (TextView) view.findViewById(R.id.brick_set_variable_edit_text); prototypeText.setVisibility(View.GONE); variableFormula.setTextFieldId(R.id.brick_set_variable_edit_text); variableFormula.refreshTextField(view); textField.setVisibility(View.VISIBLE); textField.setOnClickListener(this); Spinner variableSpinner = (Spinner) view.findViewById(R.id.set_variable_spinner); UserVariableAdapter userVariableAdapter = ProjectManager.getInstance().getCurrentProject() .getUserVariables().createUserVariableAdapter(context, sprite); UserVariableAdapterWrapper userVariableAdapterWrapper = new UserVariableAdapterWrapper(context, userVariableAdapter); userVariableAdapterWrapper.setItemLayout(android.R.layout.simple_spinner_item, android.R.id.text1); variableSpinner.setAdapter(userVariableAdapterWrapper); if (!(checkbox.getVisibility() == View.VISIBLE)) { variableSpinner.setClickable(true); variableSpinner.setEnabled(true); } else { variableSpinner.setClickable(false); variableSpinner.setFocusable(false); } setSpinnerSelection(variableSpinner, null); variableSpinner.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (((Spinner) view).getSelectedItemPosition() == 0 && ((Spinner) view).getAdapter().getCount() == 1) { NewVariableDialog dialog = new NewVariableDialog((Spinner) view); dialog.addVariableDialogListener(SetVariableBrick.this); dialog.show(((FragmentActivity) view.getContext()).getSupportFragmentManager(), NewVariableDialog.DIALOG_FRAGMENT_TAG); return true; } } return false; } }); variableSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0 && ((UserVariableAdapterWrapper) parent.getAdapter()).isTouchInDropDownView()) { NewVariableDialog dialog = new NewVariableDialog((Spinner) parent); dialog.addVariableDialogListener(SetVariableBrick.this); dialog.show(((FragmentActivity) view.getContext()).getSupportFragmentManager(), NewVariableDialog.DIALOG_FRAGMENT_TAG); } ((UserVariableAdapterWrapper) parent.getAdapter()).resetIsTouchInDropDownView(); userVariable = (UserVariable) parent.getItemAtPosition(position); adapterView = parent; } @Override public void onNothingSelected(AdapterView<?> arg0) { userVariable = null; } }); return view; }
From source file:com.androzic.waypoint.WaypointDetails.java
@SuppressLint("NewApi") private void updateWaypointDetails(double lat, double lon) { Androzic application = Androzic.getApplication(); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.getSupportActionBar().setTitle(waypoint.name); View view = getView();//from ww w .ja va 2 s. c om final TextView coordsView = (TextView) view.findViewById(R.id.coordinates); coordsView.requestFocus(); coordsView.setTag(Integer.valueOf(StringFormatter.coordinateFormat)); coordsView.setText(StringFormatter.coordinates(" ", waypoint.latitude, waypoint.longitude)); coordsView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int format = ((Integer) coordsView.getTag()).intValue() + 1; if (format == 5) format = 0; coordsView.setText(StringFormatter.coordinates(format, " ", waypoint.latitude, waypoint.longitude)); coordsView.setTag(Integer.valueOf(format)); } }); if (waypoint.altitude != Integer.MIN_VALUE) { ((TextView) view.findViewById(R.id.altitude)) .setText("\u2336 " + StringFormatter.elevationH(waypoint.altitude)); view.findViewById(R.id.altitude).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.altitude).setVisibility(View.GONE); } if (waypoint.proximity > 0) { ((TextView) view.findViewById(R.id.proximity)) .setText("~ " + StringFormatter.distanceH(waypoint.proximity)); view.findViewById(R.id.proximity).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.proximity).setVisibility(View.GONE); } double dist = Geo.distance(lat, lon, waypoint.latitude, waypoint.longitude); double bearing = Geo.bearing(lat, lon, waypoint.latitude, waypoint.longitude); bearing = application.fixDeclination(bearing); String distance = StringFormatter.distanceH(dist) + " " + StringFormatter.angleH(bearing); ((TextView) view.findViewById(R.id.distance)).setText(distance); ((TextView) view.findViewById(R.id.waypointset)).setText(waypoint.set.name); if (waypoint.date != null) { view.findViewById(R.id.date_row).setVisibility(View.VISIBLE); ((TextView) view.findViewById(R.id.date)) .setText(DateFormat.getDateFormat(activity).format(waypoint.date) + " " + DateFormat.getTimeFormat(activity).format(waypoint.date)); } else { view.findViewById(R.id.date_row).setVisibility(View.GONE); } if ("".equals(waypoint.description)) { view.findViewById(R.id.description_row).setVisibility(View.GONE); } else { WebView description = (WebView) view.findViewById(R.id.description); String descriptionHtml; try { TypedValue tv = new TypedValue(); Theme theme = activity.getTheme(); Resources resources = getResources(); theme.resolveAttribute(android.R.attr.textColorPrimary, tv, true); int secondaryColor = resources.getColor(tv.resourceId); String css = String.format( "<style type=\"text/css\">html,body{margin:0;background:transparent} *{color:#%06X}</style>\n", (secondaryColor & 0x00FFFFFF)); descriptionHtml = css + waypoint.description; description.setWebViewClient(new WebViewClient() { @SuppressLint("NewApi") @Override public void onPageFinished(WebView view, String url) { view.setBackgroundColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) view.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); } }); description.setBackgroundColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) description.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); } catch (Resources.NotFoundException e) { description.setBackgroundColor(Color.LTGRAY); descriptionHtml = waypoint.description; } WebSettings settings = description.getSettings(); settings.setDefaultTextEncodingName("utf-8"); settings.setAllowFileAccess(true); Uri baseUrl = Uri.fromFile(new File(application.dataPath)); description.loadDataWithBaseURL(baseUrl.toString() + "/", descriptionHtml, "text/html", "utf-8", null); view.findViewById(R.id.description_row).setVisibility(View.VISIBLE); } }