List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.zhongsou.souyue.ui.indicator.CheckTabPageIndicator.java
private void addTab(CharSequence text, int index) { // final TabView tabView = new TabView(getContext()); // tabView.mIndex = index; final TextView tabView = new TextView(getContext()); tabView.setTag(index);//from w ww . jav a2 s .com if (index == 0) { doSetTextStyle(tabView, R.drawable.sy_indicator_icommentary_left); } else if (index == count - 1) { doSetTextStyle(tabView, R.drawable.sy_indicator_icommentary_right); } else { doSetTextStyle(tabView, R.drawable.sy_indicator_icommentary_middle); } tabView.setFocusable(true); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, FILL_PARENT, 1)); }
From source file:fr.shywim.antoinedaniel.ui.fragment.NewsFragment.java
public void fetchBadNewsPost(final String url) { mPostsBadLayout.removeView(mPostsBadLayout.findViewById(R.id.post_error)); mPostsBadLayout.findViewById(R.id.progress).setVisibility(View.VISIBLE); Ion.with(mContext).load(url).asJsonObject().withResponse() .setCallback(new FutureCallback<Response<JsonObject>>() { @Override//w w w. j a v a 2s. c o m public void onCompleted(Exception e, Response<JsonObject> result) { mPostsBadLayout.findViewById(R.id.progress).setVisibility(View.GONE); if (e != null) { e.printStackTrace(); Crashlytics.logException(e); return; } JsonObject jo = result.getResult(); if (jo != null) { String message = jo.get("message") != null ? jo.get("message").getAsString() : ""; final String link = jo.get("link") != null ? jo.get("link").getAsString() : null; View postCard = LayoutInflater.from(mContext).inflate(R.layout.post_bad, mPostsBadLayout, false); ((TextView) postCard.findViewById(R.id.message)).setText(message); if (link != null) { postCard.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link)); mContext.startActivity(intent); } }); } mPostsBadLayout.addView(postCard); } else { TextView tv = (TextView) mPostsBadLayout.findViewById(R.id.post_error); if (tv == null) { tv = (TextView) LayoutInflater.from(mContext).inflate(R.layout.simple_textview, mPostsBadLayout, false); } tv.setText( "Problme lors de la rception des donnes, " + "cliquez pour ressayer"); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fetchBadNewsPost(url); } }); mPostsBadLayout.addView(tv); } } }); }
From source file:eu.power_switch.gui.fragment.settings.GeneralSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_general_settings, container, false); final Fragment fragment = this; CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() { @Override//from w ww. j a v a 2 s . co m public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.checkBox_autoDiscover: SmartphonePreferencesHandler.setAutoDiscover(isChecked); break; case R.id.checkBox_autoCollapseRooms: SmartphonePreferencesHandler.setAutoCollapseRooms(isChecked); break; case R.id.checkBox_autoCollapseTimers: SmartphonePreferencesHandler.setAutoCollapseTimers(isChecked); break; case R.id.checkBox_showRoomAllOnOffButtons: SmartphonePreferencesHandler.setShowRoomAllOnOff(isChecked); break; case R.id.checkBox_hideAddFAB: SmartphonePreferencesHandler.setUseOptionsMenuInsteadOfFAB(isChecked); break; case R.id.checkBox_vibrateOnButtonPress: SmartphonePreferencesHandler.setVibrateOnButtonPress(isChecked); if (isChecked) { vibrationDurationLayout.setVisibility(View.VISIBLE); } else { vibrationDurationLayout.setVisibility(View.GONE); } break; case R.id.checkBox_highlightLastActivatedButton: SmartphonePreferencesHandler.setHighlightLastActivatedButton(isChecked); // force receiver widget update ReceiverWidgetProvider.forceWidgetUpdate(getContext()); break; default: break; } } }; // setup hidden developer menu TextView generalSettingsTextView = (TextView) rootView.findViewById(R.id.TextView_generalSettings); generalSettingsTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar currentTime = Calendar.getInstance(); if (devMenuFirstClickTime != null) { Calendar latestTime = Calendar.getInstance(); latestTime.setTime(devMenuFirstClickTime.getTime()); latestTime.add(Calendar.SECOND, 5); if (currentTime.after(latestTime)) { devMenuClickCounter = 0; } } devMenuClickCounter++; if (devMenuClickCounter == 1) { devMenuFirstClickTime = currentTime; } if (devMenuClickCounter >= 5) { devMenuClickCounter = 0; DeveloperOptionsDialog developerOptionsDialog = new DeveloperOptionsDialog(); developerOptionsDialog.show(getActivity().getSupportFragmentManager(), null); } } }); startupDefaultTab = (Spinner) rootView.findViewById(R.id.spinner_startupDefaultTab); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.main_tab_names, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); startupDefaultTab.setAdapter(adapter); startupDefaultTab.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SmartphonePreferencesHandler.setStartupDefaultTab(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); autoDiscover = (CheckBox) rootView.findViewById(R.id.checkBox_autoDiscover); autoDiscover.setOnCheckedChangeListener(onCheckedChangeListener); autoCollapseRooms = (CheckBox) rootView.findViewById(R.id.checkBox_autoCollapseRooms); autoCollapseRooms.setOnCheckedChangeListener(onCheckedChangeListener); autoCollapseTimers = (CheckBox) rootView.findViewById(R.id.checkBox_autoCollapseTimers); autoCollapseTimers.setOnCheckedChangeListener(onCheckedChangeListener); showRoomAllOnOffButtons = (CheckBox) rootView.findViewById(R.id.checkBox_showRoomAllOnOffButtons); showRoomAllOnOffButtons.setOnCheckedChangeListener(onCheckedChangeListener); hideAddFAB = (CheckBox) rootView.findViewById(R.id.checkBox_hideAddFAB); hideAddFAB.setOnCheckedChangeListener(onCheckedChangeListener); highlightLastActivatedButton = (CheckBox) rootView.findViewById(R.id.checkBox_highlightLastActivatedButton); highlightLastActivatedButton.setOnCheckedChangeListener(onCheckedChangeListener); vibrateOnButtonPress = (CheckBox) rootView.findViewById(R.id.checkBox_vibrateOnButtonPress); vibrateOnButtonPress.setOnCheckedChangeListener(onCheckedChangeListener); vibrationDurationLayout = (LinearLayout) rootView.findViewById(R.id.linearLayout_vibrationDuration); vibrationDuration = (EditText) rootView.findViewById(R.id.editText_vibrationDuration); vibrationDuration.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s != null && s.length() > 0) { SmartphonePreferencesHandler.setVibrationDuration(Integer.valueOf(s.toString())); } } }); keepHistoryDuration = (Spinner) rootView.findViewById(R.id.spinner_keep_history); ArrayAdapter<CharSequence> adapterHistory = ArrayAdapter.createFromResource(getContext(), R.array.keep_history_selection_names, android.R.layout.simple_spinner_item); adapterHistory.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); keepHistoryDuration.setAdapter(adapterHistory); keepHistoryDuration.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SmartphonePreferencesHandler.setKeepHistoryDuration(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); textView_backupPath = (TextView) rootView.findViewById(R.id.textView_backupPath); Button button_changeBackupPath = (Button) rootView.findViewById(R.id.button_changeBackupPath); button_changeBackupPath.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!PermissionHelper.isWriteExternalStoragePermissionAvailable(getContext())) { Snackbar snackbar = Snackbar.make(rootView, R.string.missing_external_storage_permission, Snackbar.LENGTH_LONG); snackbar.setAction(R.string.grant, new View.OnClickListener() { @Override public void onClick(View v) { ActivityCompat.requestPermissions(MainActivity.getActivity(), new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, PermissionConstants.REQUEST_CODE_STORAGE_PERMISSION); } }); snackbar.show(); } PathChooserDialog pathChooserDialog = PathChooserDialog.newInstance(); pathChooserDialog.setTargetFragment(fragment, 0); pathChooserDialog.show(getActivity().getSupportFragmentManager(), null); } }); View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.radioButton_darkBlue: SmartphonePreferencesHandler.setTheme(SettingsConstants.THEME_DARK_BLUE); break; case R.id.radioButton_lightBlue: SmartphonePreferencesHandler.setTheme(SettingsConstants.THEME_LIGHT_BLUE); break; case R.id.radioButton_dayNight_blue: SmartphonePreferencesHandler.setTheme(SettingsConstants.THEME_DAY_NIGHT_BLUE); break; default: break; } getActivity().finish(); Intent intent = new Intent(getContext(), MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }; radioButtonDarkBlue = (RadioButton) rootView.findViewById(R.id.radioButton_darkBlue); radioButtonDarkBlue.setOnClickListener(onClickListener); radioButtonLightBlue = (RadioButton) rootView.findViewById(R.id.radioButton_lightBlue); radioButtonLightBlue.setOnClickListener(onClickListener); radioButtonDayNightBlue = (RadioButton) rootView.findViewById(R.id.radioButton_dayNight_blue); radioButtonDayNightBlue.setOnClickListener(onClickListener); sendLogsProgress = (ProgressBar) rootView.findViewById(R.id.sendLogsProgress); sendLogs = (Button) rootView.findViewById(R.id.button_sendLogs); sendLogs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendLogs.setEnabled(false); sendLogsProgress.setVisibility(View.VISIBLE); new AsyncTask<Void, Void, AsyncTaskResult<Boolean>>() { @Override protected AsyncTaskResult<Boolean> doInBackground(Void... params) { try { LogHandler.sendLogsAsMail(getContext()); return new AsyncTaskResult<>(true); } catch (Exception e) { return new AsyncTaskResult<>(e); } } @Override protected void onPostExecute(AsyncTaskResult<Boolean> booleanAsyncTaskResult) { if (booleanAsyncTaskResult.isSuccess()) { // all is good } else { if (booleanAsyncTaskResult.getException() instanceof MissingPermissionException) { Snackbar snackbar = Snackbar.make(rootView, R.string.missing_external_storage_permission, Snackbar.LENGTH_LONG); snackbar.setAction(R.string.grant, new View.OnClickListener() { @Override public void onClick(View v) { ActivityCompat.requestPermissions(MainActivity.getActivity(), new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, PermissionConstants.REQUEST_CODE_STORAGE_PERMISSION); } }); snackbar.show(); } else { StatusMessageHandler.showErrorMessage(getContext(), booleanAsyncTaskResult.getException()); } } sendLogs.setEnabled(true); sendLogsProgress.setVisibility(View.GONE); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(this, "received intent: " + intent.getAction()); updateUI(); } }; return rootView; }
From source file:com.example.aitor2.myapplication.DrawerArrowSample.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); setContentView(R.layout.home_view);/*w ww . j ava 2s.c o m*/ final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); final ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator); final Resources resources = getResources(); drawer_adapter adapter = new drawer_adapter(this, icons, titles); ListView lv = (ListView) findViewById(R.id.drawer_listview); lv.setAdapter(adapter); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { drawer.closeDrawer(START); if (position == 0) { Intent intent = new Intent(DrawerArrowSample.this, DrawerArrowSample.class); startActivity(intent); finish(); } else if (position == 1) { Intent intent = new Intent(DrawerArrowSample.this, misReservas.class); startActivity(intent); finish(); } } }); findViewById(R.id.pink_icon).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(DrawerArrowSample.this, "Clicked pink Floating Action Button", Toast.LENGTH_SHORT) .show(); } }); actionB = (FloatingActionButton) findViewById(R.id.pink_icon); actionB.setStrokeVisible(true); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_main_swipe_refresh_layout); swipeRefreshLayout.setOnRefreshListener(onRefreshListener); swipeRefreshLayout.setColorSchemeColors(Color.BLACK, Color.GREEN, Color.BLACK, Color.GREEN); drawerArrowDrawable = new DrawerArrowDrawable(resources); drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray)); imageView.setImageDrawable(drawerArrowDrawable); drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() { @Override public void onDrawerSlide(View drawerView, float slideOffset) { offset = slideOffset; // Sometimes slideOffset ends up so close to but not quite 1 or 0. if (slideOffset >= .995) { flipped = true; drawerArrowDrawable.setFlip(flipped); } else if (slideOffset <= .005) { flipped = false; drawerArrowDrawable.setFlip(flipped); } drawerArrowDrawable.setParameter(offset); } }); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (drawer.isDrawerVisible(START)) { drawer.closeDrawer(START); } else { drawer.openDrawer(START); } } }); final TextView styleButton = (TextView) findViewById(R.id.indicator_style); styleButton.setOnClickListener(new View.OnClickListener() { boolean rounded = false; @Override public void onClick(View v) { styleButton.setText(rounded // ? resources.getString(R.string.rounded) // : resources.getString(R.string.squared)); rounded = !rounded; drawerArrowDrawable = new DrawerArrowDrawable(resources, rounded); drawerArrowDrawable.setParameter(offset); drawerArrowDrawable.setFlip(flipped); drawerArrowDrawable.setStrokeColor(resources.getColor(R.color.light_gray)); imageView.setImageDrawable(drawerArrowDrawable); } }); /////////////////////create expandable listview new expandable().execute(); ////////////////////calendario // Pop up Date picker on pressing the editText }
From source file:me.albinmathew.celluloid.ui.fragments.MovieDetailFragment.java
public void showReviews(@NonNull List<ReviewResponseBean> reviews) { if (reviews.isEmpty()) { mReviewsLabel.setVisibility(View.GONE); mReviewsView.setVisibility(View.GONE); } else {//from ww w . j av a 2 s . c o m mReviewsLabel.setVisibility(View.VISIBLE); mReviewsView.setVisibility(View.VISIBLE); mReviewsView.removeAllViews(); if (mContext != null && isAdded()) { LayoutInflater inflater = getActivity().getLayoutInflater(); for (ReviewResponseBean review : reviews) { ViewGroup reviewContainer = (ViewGroup) inflater.inflate(R.layout.review, mReviewsView, false); TextView reviewAuthor = (TextView) reviewContainer.findViewById(R.id.review_author); TextView reviewContent = (TextView) reviewContainer.findViewById(R.id.review_content); reviewAuthor.setText(review.getAuthor()); reviewContent.setText(review.getContent()); reviewAuthor.setPadding(10, 10, 10, 10); reviewContent.setPadding(10, 10, 10, 10); reviewContent.setOnClickListener(this); mReviewsView.addView(reviewContainer); } } } }
From source file:com.duy.pascal.ui.editor.BaseEditorActivity.java
private void addCustomTab() { mTabLayout.setCustomTabView(new SmartTabLayout.TabProvider() { @Override/*from www . java 2 s . c o m*/ public View createTabView(ViewGroup container, final int position, PagerAdapter adapter) { LayoutInflater inflater = LayoutInflater.from(BaseEditorActivity.this); View view = inflater.inflate(R.layout.item_tab_file, container, false); View close = view.findViewById(R.id.img_close); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { removePage(position); } }); TextView txtTitle = view.findViewById(R.id.txt_name); txtTitle.setText(adapter.getPageTitle(position)); txtTitle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(position); } }); if (position == mViewPager.getCurrentItem()) { txtTitle.setSelected(true); } return view; } }); }
From source file:com.anjuke.library.uicomponent.slidingtab.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w ww.j a v a 2 s .c o m*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.fjoglar.etsitnoticias.utils.UiUtils.java
/** * Configure the TextViews that will show the attachments of the new. * * @param textView TextView to be configured. * @param title Text shown in TextView * @param downloadLink Link attached to TextView. * @param fileType Type of file of the attachment. * @param context The context of activity. *//*from w w w . j av a2s . c o m*/ public static void configureTextView(TextView textView, String title, final String downloadLink, Attachment.FILE_TYPE fileType, final Context context) { final int TEXT_VIEW_MIN_HEIGHT = 40; final int TEXT_VIEW_MARGIN_TOP = 4; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.setMargins(0, convertDpToPx(TEXT_VIEW_MARGIN_TOP, context), 0, 0); textView.setLayoutParams(params); textView.setText(title); textView.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL)); textView.setMinHeight(convertDpToPx(TEXT_VIEW_MIN_HEIGHT, context)); textView.setGravity(Gravity.CENTER_VERTICAL); switch (fileType) { case FILE: textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file, 0, 0, 0); break; case IMAGE: textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_photo, 0, 0, 0); break; case FOLDER: textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_folder, 0, 0, 0); break; default: textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_link, 0, 0, 0); break; } textView.setCompoundDrawablePadding(convertDpToPx(4, context)); TypedValue typedValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true); textView.setBackgroundResource(typedValue.resourceId); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Navigator.getInstance().openUrl(context, downloadLink); } }); }
From source file:com.xxjwd.libs.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); /* w w w . j av a 2 s. c o m*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setText(title); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:ca.appvelopers.mcgillmobile.ui.ScheduleActivity.java
/** * Shows a dialog with course information * * @param course Clicked course/*from w ww .j a v a2 s. c o m*/ */ public void showCourseDialog(final Course course) { analytics.sendScreen("Schedule - Course"); //Inflate the body View layout = View.inflate(this, R.layout.dialog_course, null); //Title TextView title = (TextView) layout.findViewById(R.id.course_title); title.setText(course.getTitle()); //Time TextView time = (TextView) layout.findViewById(R.id.course_time); time.setText(course.getTimeString()); //Location TextView location = (TextView) layout.findViewById(R.id.course_location); location.setText(course.getLocation()); //Type TextView type = (TextView) layout.findViewById(R.id.course_type); type.setText(course.getType()); //Instructor TextView instructor = (TextView) layout.findViewById(R.id.course_instructor); instructor.setText(course.getInstructor()); //Section TextView section = (TextView) layout.findViewById(R.id.course_section); section.setText(course.getSection()); //Credits TextView credits = (TextView) layout.findViewById(R.id.course_credits); credits.setText(String.valueOf(course.getCredits())); //CRN TextView crn = (TextView) layout.findViewById(R.id.course_crn); crn.setText(String.valueOf(course.getCRN())); //Docuum Link TextView docuum = (TextView) layout.findViewById(R.id.course_docuum); docuum.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.openURL(ScheduleActivity.this, "http://www.docuum.com/mcgill/" + course.getSubject().toLowerCase() + "/" + course.getNumber()); } }); //Show on Map TextView map = (TextView) layout.findViewById(R.id.course_map); map.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO } }); new AlertDialog.Builder(this).setTitle(course.getCode()).setView(layout).setCancelable(true) .setNeutralButton(R.string.done, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); }