Example usage for android.widget TextView setOnClickListener

List of usage examples for android.widget TextView setOnClickListener

Introduction

In this page you can find the example usage for android.widget TextView setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.desno365.mods.Tabs.FragmentTab7.java

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragmenttab7, container, false); // xml tab

    TextView textVersion = (TextView) rootView.findViewById(R.id.latest_version_unreal_is); // id TextView version
    textVersion.setText(MainActivity.modsContainer.unreal.getVersion()); // MainActivity variable that holds the latest version

    TextView textCompatibility = (TextView) rootView.findViewById(R.id.unreal_compatibility); // id TextView compatibility
    textCompatibility.setText(MainActivity.modsContainer.unreal.getCompatibility()); // MainActivity variable that holds the versions compatibility

    final TextView textChangelog = (TextView) rootView.findViewById(R.id.unreal_changelog); // id TextView changelog
    textChangelog.setText(android.text.Html.fromHtml(MainActivity.modsContainer.unreal.getChangelog())); // MainActivity variable that holds the latest changelog
    textChangelog.setMovementMethod(android.text.method.LinkMovementMethod.getInstance());
    textChangelog.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES);

    final TextView textShowHide = (TextView) rootView.findViewById(R.id.changelog_show_hide_tab7); // id TextView show/hide changelog
    textShowHide.setText(getResources().getString(R.string.show_changelog));
    textShowHide.setOnClickListener(new View.OnClickListener() {
        @Override//from www. ja v  a  2  s  .c o  m
        public void onClick(View v) {

            if (!displayingAllChangelog) {

                // get the TextView height that will be used when hiding the changelog
                changelogHiddenHeight = textChangelog.getHeight();

                DesnoUtils.expandTextView(container, textChangelog);

                displayingAllChangelog = true;
                textShowHide.setText(getResources().getString(R.string.hide_changelog));

            } else {

                DesnoUtils.collapseTextView(container, textChangelog, changelogHiddenHeight);

                displayingAllChangelog = false;
                textShowHide.setText(getResources().getString(R.string.show_changelog));
            }
        }
    });

    // make the show/hide button invisible if it is not necessary
    ViewTreeObserver vto = textShowHide.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if (textChangelog.getLineCount() <= SharedConstants.CHANGELOG_TEXT_MAX_LINES) {
                textShowHide.setVisibility(View.GONE);
            } else {
                textShowHide.setVisibility(View.VISIBLE);
            }
        }
    });

    return rootView;
}

From source file:co.dilaver.quoter.fragments.AboutMeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_about_me, container, false);

    TextView mail = (TextView) view.findViewById(R.id.tvEmail);
    TextView twitter = (TextView) view.findViewById(R.id.tvTwitter);
    TextView facebook = (TextView) view.findViewById(R.id.tvFacebook);
    TextView linkedIn = (TextView) view.findViewById(R.id.tvLinkedIn);

    mail.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  w w  .  ja  va2s .c  o m*/
        public void onClick(View v) {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
            emailIntent.setData(Uri.parse("mailto: mdilaveroglu@gmail.com"));
            startActivity(emailIntent);
        }
    });
    twitter.setMovementMethod(LinkMovementMethod.getInstance());
    facebook.setMovementMethod(LinkMovementMethod.getInstance());
    linkedIn.setMovementMethod(LinkMovementMethod.getInstance());

    return view;
}

From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java

@Override
public void onClearSelected() {

    closeMenu();/*from   ww w  .j ava 2s  .  com*/

    LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inf.inflate(R.layout.popclear_layout, null, false);

    final PopupWindow pw = new PopupWindow(v);
    pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);

    TextView yesTxt = (TextView) v.findViewById(R.id.dlgYes);
    TextView noTxt = (TextView) v.findViewById(R.id.dlgNo);
    noTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    yesTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            pinTableFrag.clearBoard();
        }
    });

    pw.showAtLocation(v, Gravity.CENTER, 0, 0);

}

From source file:com.fullmeadalchemist.mustwatch.ui.log.form.LogFormFragment.java

private void initClickListeners() {
    TextView dateField = getActivity().findViewById(R.id.createDateDate);
    if (dateField != null) {
        dateField.setOnClickListener(v -> {
            Log.i(TAG, "Date was clicked!");
            DialogFragment newFragment = new DatePickerFragment();
            Bundle args = new Bundle();
            args.putInt(YEAR, viewModel.logEntry.entryDate.get(Calendar.YEAR));
            args.putInt(MONTH, viewModel.logEntry.entryDate.get(Calendar.MONTH));
            args.putInt(DAY_OF_MONTH, viewModel.logEntry.entryDate.get(Calendar.DAY_OF_MONTH));
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, DATE_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "datePicker");
        });//from ww w  .j  a va 2s .c o  m
    }

    TextView timeField = getActivity().findViewById(R.id.createDateTime);
    if (timeField != null) {
        timeField.setOnClickListener(v -> {
            Log.i(TAG, "Time was clicked!");
            DialogFragment newFragment = new TimePickerFragment();
            Bundle args = new Bundle();
            args.putInt(HOUR, viewModel.logEntry.entryDate.get(Calendar.HOUR));
            args.putInt(MINUTE, viewModel.logEntry.entryDate.get(Calendar.MINUTE));
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, TIME_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "timePicker");
        });
    }

    Button submitButton = getActivity().findViewById(R.id.button_submit);
    if (submitButton != null) {
        submitButton.setOnClickListener(v -> {
            Log.i(TAG, "Submit button clicked!");

            TextView phTv = getActivity().findViewById(R.id.ph);
            if (phTv != null) {
                viewModel.logEntry.acidity = toFloat(phTv.getText().toString().trim());
            }

            TextView sgTv = getActivity().findViewById(R.id.sg);
            if (sgTv != null) {
                viewModel.logEntry.sg = toFloat(sgTv.getText().toString().trim());
            }

            TextView noteTv = getActivity().findViewById(R.id.notes);
            if (noteTv != null) {
                viewModel.logEntry.note = noteTv.getText().toString().trim();
            }

            viewModel.saveNewLogEntry();
            navigationController.navigateToBatchDetail(this.batchId);
        });
    }
}

From source file:mobisocial.musubi.ui.FeedPannerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mNfc = new Nfc(this);
    mFeedManager = new FeedManager(App.getDatabaseSource(this));
    mObserver = new LessSpammyContentObserver(new Handler(getMainLooper())) {
        @Override//from w  w  w. ja  v a  2 s  . com
        public void lessSpammyOnChange(boolean arg0) {
            long feedId = Long.parseLong(mFeedUri.getLastPathSegment());
            String feedName = UiUtil.getFeedNameFromMembersList(mFeedManager, mFeedManager.lookupFeed(feedId));
            Spannable feedSpan = EmojiSpannableFactory.getInstance(FeedPannerActivity.this)
                    .newSpannable(feedName);
            setTitle(feedSpan);
        }
    };

    setContentView(R.layout.activity_feed_home);
    mDualPane = findViewById(R.id.feed_pager) == null;
    if (mDualPane) {
        Intent i = new Intent();
        i.setData(getIntent().getData());
        i.setClass(this, FeedListActivity.class);
        finish();
        return;
    }

    mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    mFeedViewPager = (ViewPager) findViewById(R.id.feed_pager);
    mFeedViewPager.setOnPageChangeListener(this);

    int id = getResources().getIdentifier("action_bar_title", "id", "android");
    if (id == 0)
        id = R.id.abs__action_bar_title;
    TextView mTitle = (TextView) findViewById(id);
    mTitle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(FeedPannerActivity.this, FeedDetailsActivity.class);
            intent.setDataAndType(mFeedUri, MusubiContentProvider.getType(Provided.FEEDS_ID));
            startActivity(intent);
        }
    });

    setTitle("Musubi Conversation");

    if (getIntent() != null && getIntent().getData() != null) {
        mFeedUri = getIntent().getData();
    }
    //clear the intent so we dont try to scroll to that page again
    setIntent(null);
    mFragmentAdapter = new FeedFragmentAdapter();
    mFeedViewPager.setAdapter(mFragmentAdapter);
    getSupportLoaderManager().initLoader(0, null, this);
}

From source file:info.papdt.blacklight.ui.common.LinearViewPagerIndicator.java

public void addTab(String title) {
    if (mMeasured) {
        throw new IllegalStateException("Cannot add tabs when measured");
    }//from ww w.  j a  va2  s. c o  m

    TextView tv = new TextView(mContext);
    tv.setText(title);
    tv.setTextColor(mForeground);
    tv.setGravity(Gravity.CENTER);
    tv.setTag(getChildCount());
    tv.setOnClickListener(this);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    params.weight = 1.0f;
    addView(tv, params);
}

From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java

@Override
public void onSaveSelected() {
    closeMenu();//w  w w  .  j  a  v a 2  s .c o m

    LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inf.inflate(R.layout.popsave_layout, null, false);

    final PopupWindow pw = new PopupWindow(v);
    pw.setFocusable(true);
    pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);

    final EditText edt = (EditText) v.findViewById(R.id.edtFileName);

    TextView saveTxt = (TextView) v.findViewById(R.id.dlgSave);
    TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel);
    cancelTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    saveTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            Bitmap b = pinTableFrag.createBitmap();
            try {
                ImageUtility.saveImage(b, edt.getEditableText().toString(), DreamPinsActivity.this);
            } catch (SaveFileException sfe) {
                Toast.makeText(DreamPinsActivity.this, getResources().getText(R.string.msgSaveFileError),
                        Toast.LENGTH_LONG).show();
            }
        }
    });

    pw.showAtLocation(v, Gravity.CENTER, 0, 0);

}

From source file:eu.inmite.apps.smsjizdenka.framework.about.BaseAboutFragment.java

private void setupVersion(TextView vVersion) {
    vVersion.setText("v. " + App.getAppVersionName() + (App.isReleaseBuild() ? "" : "-debug"));
    if (!TextUtils.isEmpty(getEasterEggText())) {
        vVersion.setOnClickListener(new View.OnClickListener() {

            int clicks = 0;

            @Override//from  w w  w . ja v  a  2  s  .  co m
            public void onClick(View view) {
                if (clicks++ > 4) {
                    SimpleDialogFragment.createBuilder(mContext, getFragmentManager())
                            .setMessage(getEasterEggText()).show();
                }

            }
        });
    }
}

From source file:com.jasonchen.microlang.view.LinearViewPagerIndicator.java

public void addTab(String title) {
    if (mMeasured) {
        throw new IllegalStateException("Cannot add tabs when measured");
    }/*from  w  w  w . j  a v  a 2 s . c  om*/

    TextView tv = new TextView(mContext);
    tv.setText(title);
    tv.setTextColor(mForeground);
    tv.setGravity(Gravity.CENTER);
    tv.setTag(getChildCount());
    tv.setOnClickListener(this);
    tv.setBackground(getBackground());
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    params.weight = 1.0f;
    addView(tv, params);
}

From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java

public void onBackgroundSelected() {
    LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inf.inflate(R.layout.popbkg_layout, null, false);

    final PopupWindow pw = new PopupWindow(v);
    pw.setFocusable(true);/* w w w. j  ava 2s.  c  om*/
    pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);

    TextView changeTxt = (TextView) v.findViewById(R.id.dlgChange);
    TextView resetTxt = (TextView) v.findViewById(R.id.dlgReset);
    TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel);
    cancelTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    resetTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            pinTableFrag.setBackground(R.drawable.tilebkg);
        }
    });

    changeTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            // Start a new Intent to get the picture from the Gallery
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(intent, SELECT_PICTURE);
        }
    });

    pw.showAtLocation(v, Gravity.CENTER, 0, 0);

}