List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.ibm.mil.readyapps.physio.fragments.library.VideoFragment.java
private void setupView(View view) { Exercise exercise = DataManager.getCurrentPatient().getSelectedExercise(); TextView exerciseName = (TextView) view.findViewById(R.id.exercise_name); exerciseName.setTypeface(AndroidUtils.robotoRegular(exerciseName.getContext())); exerciseName.setText(exercise.getDescription()); List<Routine> routines = DataManager.getCurrentPatient().getRoutines(); Routine routine = DataManager.getCurrentPatient().getSelectedRoutine(); int routineIndex = routines.indexOf(routine); TextView routineName = (TextView) view.findViewById(R.id.routine_name); routineName.setText((routineIndex + 1) + " of " + routines.size()); TextView minutesValue = (TextView) view.findViewById(R.id.minutes_value); minutesValue.setTypeface(AndroidUtils.robotoBold(minutesValue.getContext())); minutesValue.setText(Utils.zeroPaddedNumber(exercise.getMinutes(), 2)); TextView repetitionsValue = (TextView) view.findViewById(R.id.repetitions_value); repetitionsValue.setTypeface(AndroidUtils.robotoBold(repetitionsValue.getContext())); repetitionsValue.setText(Utils.zeroPaddedNumber(exercise.getRepetitions(), 2)); TextView setsValue = (TextView) view.findViewById(R.id.sets_value); setsValue.setTypeface(AndroidUtils.robotoBold(setsValue.getContext())); setsValue.setText(Utils.zeroPaddedNumber(exercise.getSets(), 2)); TextView toolsValue = (TextView) view.findViewById(R.id.tools); toolsValue.setText(exercise.getTools()); TextView endRoutine = (TextView) view.findViewById(R.id.end_routine_button); endRoutine.setTypeface(AndroidUtils.robotoRegular(endRoutine.getContext())); endRoutine.setOnClickListener(new View.OnClickListener() { @Override//from w ww .jav a2 s .c o m public void onClick(View v) { getFragmentManager().beginTransaction().replace(R.id.fragment_container, new EndRoutineFragment()) .addToBackStack(null).commit(); } }); TextView nextExercise = (TextView) view.findViewById(R.id.next_exercise_button); nextExercise.setTypeface(AndroidUtils.robotoRegular(nextExercise.getContext())); nextExercise.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Exercise nextExercise = nextExercise(); if (nextExercise != null) { DataManager.getCurrentPatient().setSelectedExercise(nextExercise); showNextExerciseDialog(); } else { showFinalExerciseDialog(); } } }); YouTubePlayerSupportFragment player = new YouTubePlayerSupportFragment(); player.initialize(YOUTUBE_API_KEY, this); getChildFragmentManager().beginTransaction().add(R.id.youtube_container, player).commit(); }
From source file:com.cyanogenmod.eleven.widgets.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { final TextView textView = new TextView(getContext()); textView.setText(tabTitle);//from w w w.j a v a 2 s. co m textView.setBackgroundResource(R.drawable.view_pager_tab_background); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); textView.setOnLongClickListener(new OnTabLongClickListener(position)); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(textView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; textView.setSelected(true); } }
From source file:com.jaspersoft.android.jaspermobile.widget.DraggableViewsContainer.java
private int addDraggableNote(float x, float y) { int viewId = getChildCount(); TextView textView = new TextView(getContext()); textView.setTextColor(mColor);/*from w w w . ja v a2s. c o m*/ textView.setTextSize(10 + mSize * 2); textView.setX(x); textView.setY(y); textView.setId(viewId); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showTextInputDialog(v.getId(), ((TextView) v).getText().toString()); } }); textView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { ClipData data = ClipData.newPlainText(String.valueOf(v.getId()), ""); View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v); v.startDrag(data, shadowBuilder, null, 0); return true; } }); addView(textView); return viewId; }
From source file:it_minds.dk.eindberetningmobil_android.views.StartActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //if there are any ongoing trips, go to the monitoring class then. if (!MainSettings.getInstance(this).getServiceClosed() && MonitoringService.isServiceActive()) { startActivity(new Intent(this, MonitoringActivity.class)); finish();// www . j a v a2 s. c om return; } setContentView(R.layout.start_tracking_layout); TextView dateLabel = getViewById(R.id.start_tracking_layout_date_label); dateLabel.setText(getString(R.string.date_start) + new DateTime().toString("dd/MM-yy")); handlePurpose(R.id.start_tracking_layout_purpose, R.id.start_tracking_layout_purpose_description); handleOrgLocation(R.id.start_tracking_layout_org_location, R.id.start_tracking_layout_org_location_description); handleRate(R.id.start_tracking_layout_rate, R.id.start_tracking_layout_rate_desc); handleExtraDesc(R.id.start_tracking_layout_extra_desc, R.id.start_tracking_layout_extra_desc_desc); CheckBox cb = getViewById(R.id.start_tracking_layout_start_at_home); cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { report.setstartedAtHome(isChecked); } }); TextView startBtn = getViewById(R.id.start_tracking_layout_start_btn); startBtn.setOnClickListener(onStartClicked); setColorForText(startBtn); loadPreFilledData(); }
From source file:de.gebatzens.sia.dialog.LoginDialog.java
@Override public void onStart() { super.onStart(); boolean hideSid = getArguments().getBoolean("hideSid"); String sid = getArguments().getString("sid"); boolean auth = getArguments().getBoolean("auth"); String user = getArguments().getString("user"); final AlertDialog dialog = (AlertDialog) getDialog(); ((SetupActivity) getActivity()).currentLoginDialog = dialog; if (auth) {/*from w ww .ja v a 2s . co m*/ final EditText passwordInput = (EditText) dialog.findViewById(R.id.passwordInput); final CheckBox passwordToggle = (CheckBox) dialog.findViewById(R.id.passwordToggle); passwordToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { passwordInput.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordInput.setSelection(passwordInput.getText().length()); } else { passwordInput.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); passwordInput.setSelection(passwordInput.getText().length()); } } }); ((EditText) dialog.findViewById(R.id.usernameInput)).setText(user); } else { dialog.findViewById(R.id.passwordInput).setVisibility(View.GONE); dialog.findViewById(R.id.passwordToggle).setVisibility(View.GONE); dialog.findViewById(R.id.usernameInput).setVisibility(View.GONE); } if (hideSid) { dialog.findViewById(R.id.sidInput).setVisibility(View.GONE); } else { ((EditText) dialog.findViewById(R.id.sidInput)).setText(sid); } TextView acceptTermsLink = (TextView) dialog.findViewById(R.id.acceptTermsLink); acceptTermsLink.setPaintFlags(acceptTermsLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); acceptTermsLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View widget) { Intent i = new Intent(activity, TextActivity.class); i.putExtra("title", R.string.terms_title); i.putExtra("text", R.array.terms); activity.startActivity(i); } }); final CheckBox acceptTerms = (CheckBox) dialog.findViewById(R.id.acceptTerms); acceptTerms.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(isChecked); } }); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(acceptTerms.isChecked()); }
From source file:itkach.aard2.SettingsListAdapter.java
private View getAboutView(View convertView, ViewGroup parent) { View view;//from w ww. ja v a 2s .c om if (convertView != null) { view = convertView; } else { final Context context = parent.getContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.settings_about_item, parent, false); ImageView copyrightIcon = (ImageView) view.findViewById(R.id.setting_about_copyright_icon); copyrightIcon.setImageDrawable(FontIconDrawable.inflate(context, R.xml.ic_text_copyright)); ImageView licenseIcon = (ImageView) view.findViewById(R.id.setting_about_license_icon); licenseIcon.setImageDrawable(FontIconDrawable.inflate(context, R.xml.ic_text_license)); ImageView sourceIcon = (ImageView) view.findViewById(R.id.setting_about_source_icon); sourceIcon.setImageDrawable(FontIconDrawable.inflate(context, R.xml.ic_text_external_link)); String appName = context.getString(R.string.app_name); String title = context.getString(R.string.setting_about, appName); TextView titleView = (TextView) view.findViewById(R.id.setting_about); titleView.setText(title); String licenseName = context.getString(R.string.application_license_name); final String licenseUrl = context.getString(R.string.application_license_url); String license = context.getString(R.string.application_license, licenseUrl, licenseName); TextView licenseView = (TextView) view.findViewById(R.id.application_license); licenseView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse(licenseUrl); Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri); context.startActivity(browserIntent); } }); licenseView.setText(Html.fromHtml(license.trim())); PackageManager manager = context.getPackageManager(); String versionName; try { PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = "?"; } String version = context.getString(R.string.application_version, versionName); TextView versionView = (TextView) view.findViewById(R.id.application_version); versionView.setText(Html.fromHtml(version)); } return view; }
From source file:ecust.news.myWidgetTabPageIndicator.java
private void addTab(int i, String title) { TextView textView = new TextView(getContext()); textView.setText(title);//from ww w . j ava 2s . c o m //? textView = decorateTextView(textView); if (i == 0) textView.setTextColor(textViewFocusedColor); textView.setOnClickListener(this); //View linearLayout.addView(textView); }
From source file:com.r.raul.tools.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //se crea la base de datos si no existe. new MyDatabase(this); //copia debug copybd();/*from w w w . j a v a 2s. c o m*/ /***PUBLI**/ mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { super.onAdLoaded(); mAdView.setVisibility(View.VISIBLE); } }); FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); if (savedInstanceState == null) { LanzarDeviceInfo(R.id.nav_device); } else { String tag = fragmentManager.findFragmentById(R.id.container).getTag(); fragment = fragmentManager.getFragment(savedInstanceState, "frag"); fragmentManager.beginTransaction().replace(R.id.container, fragment, tag) //.addToBackStack("LISTADO") .commit(); } NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); navigationView.setCheckedItem(R.id.nav_device); ImageButton navShare = (ImageButton) navigationView.getHeaderView(0).findViewById(R.id.navShare); navShare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { compartirApp(); } }); TextView mailCabecera = (TextView) navigationView.getHeaderView(0).findViewById(R.id.mailCabecera); mailCabecera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { contactApp(); } }); ChangeLog cl = new ChangeLog(this); if (cl.isFirstRun()) { new LanzaChangelog(this).getLogDialog().show(); } }
From source file:net.olejon.mdapp.LvhAdapter.java
@Override public void onBindViewHolder(CategoryViewHolder viewHolder, int i) { try {// w w w. java 2s . com final String color; final String icon; final JSONObject categoriesJsonObject = mCategories.getJSONObject(i); switch (i) { case 0: { color = "#F44336"; icon = "lvh_urgent"; viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.red)); viewHolder.icon.setImageResource(R.drawable.ic_favorite_white_24dp); break; } case 1: { color = "#9C27B0"; icon = "lvh_symptoms"; viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.purple)); viewHolder.icon.setImageResource(R.drawable.ic_stethoscope); break; } case 2: { color = "#FF9800"; icon = "lvh_injuries"; viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.orange)); viewHolder.icon.setImageResource(R.drawable.ic_healing_white_24dp); break; } case 3: { color = "#009688"; icon = "lvh_administrative"; viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.teal)); viewHolder.icon.setImageResource(R.drawable.ic_my_library_books_white_24dp); break; } default: { color = "#009688"; icon = "lvh_administrative"; viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.teal)); viewHolder.icon.setImageResource(R.drawable.ic_my_library_books_white_24dp); } } viewHolder.title.setText(categoriesJsonObject.getString("title")); viewHolder.categories.removeAllViews(); final JSONArray categoriesJsonArray = categoriesJsonObject.getJSONArray("categories"); for (int f = 0; f < categoriesJsonArray.length(); f++) { final JSONObject categoryJsonObject = categoriesJsonArray.getJSONObject(f); final String title = categoryJsonObject.getString("title"); final String subcategories = categoryJsonObject.getString("subcategories"); TextView textView = (TextView) mLayoutInflater.inflate(R.layout.activity_lvh_card_categories_item, null); textView.setText(categoryJsonObject.getString("title")); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(mContext, LvhCategoriesActivity.class); intent.putExtra("color", color); intent.putExtra("icon", icon); intent.putExtra("title", title); intent.putExtra("subcategories", subcategories); mContext.startActivity(intent); } }); viewHolder.categories.addView(textView); } animateView(viewHolder.card, i); } catch (Exception e) { Log.e("LvhAdapter", Log.getStackTraceString(e)); } }
From source file:com.android.messaging.ui.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { final TextView textView = new TextView(getContext()); textView.setText(tabTitle);/*w w w . j a v a 2s . c o m*/ textView.setBackgroundResource(R.drawable.contact_picker_tab_background_selector); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(textView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; textView.setSelected(true); } }