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:hu.fnf.devel.atlas.Atlas.java

private void setDetailProperties(int page_id) {
    LinearLayout root = (LinearLayout) findViewById(R.id.detailcatRoot);
    root.setOrientation(android.widget.LinearLayout.VERTICAL);

    LinearLayout in = new LinearLayout(getApplicationContext());
    in.setId(AtlasData.INCOME);/*  ww  w .j  a  v  a  2s .  c  o  m*/
    in.setOnClickListener(onCatClick);

    LinearLayout out = new LinearLayout(getApplicationContext());
    out.setId(AtlasData.OUTCOME);
    out.setOnClickListener(onCatClick);

    TextView intext = new TextView(getApplicationContext());
    intext.setText(getResources().getString(R.string.income));
    intext.setOnClickListener(onCatClick);
    intext.setId(AtlasData.INCOME);
    intext.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse);

    TextView outtext = new TextView(getApplicationContext());
    outtext.setText(getResources().getString(R.string.outcome));
    outtext.setOnClickListener(onCatClick);
    outtext.setId(AtlasData.OUTCOME);
    outtext.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Medium_Inverse);

    in.addView(intext);
    out.addView(outtext);

    root.addView(in);
    addChilds(in, root);

    root.addView(out);
    addChilds(out, root);

}

From source file:com.minsheng.app.xunchedai.loan.activities.AddLoanActivity.java

protected void initPopupWindowScheme(View v) {
    popupWindow = PopupWindowUtils.newPop(this, R.layout.pop_add_loan_activity_scheme, v);

    adapter = new SchemeAdapter(list_scheme, this);
    ListView lv_scheme = (ListView) popupWindow.getContentView().findViewById(R.id.scheme_list);
    TextView tv_cancel = (TextView) popupWindow.getContentView().findViewById(R.id.cancel);

    lv_scheme.setAdapter(adapter);/*from   ww w. ja  v a2 s  .  c  o  m*/
    lv_scheme.setOnItemClickListener(this);
    tv_cancel.setOnClickListener(this);
}

From source file:com.minsheng.app.xunchedai.loan.activities.AddLoanActivity.java

/**
 * ???//w w w.j a v  a  2s .  co m
 */
public void initPopupWindowSubmit(View v) {
    popupWindow = PopupWindowUtils.newPop(this, R.layout.pop_add_loan_activity_submit, v);
    TextView tv_submit = (TextView) popupWindow.getContentView().findViewById(R.id.submit);
    TextView tv_cancel = (TextView) popupWindow.getContentView().findViewById(R.id.cancel);

    tv_submit.setOnClickListener(this);
    tv_cancel.setOnClickListener(this);
}

From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java

private void updateContentFromGG(Match data) {

    if (data == null) {
        Toast.makeText(this, "Network Connection issues", Toast.LENGTH_SHORT).show();
        return;/*from  ww w  .ja  v a  2 s .c  om*/
    }

    if (Long.parseLong(dateTime) < TimeUtils.getUTCTime()) {
        mMatchScoreView.setText(data.teamOne.score + " : " + data.teamTwo.score);
    } else {
        mMatchScoreView.setText(" vs ");
    }

    if (data.livestreams != null && data.livestreams.length != 0) {
        final ViewGroup livestreamsCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_livestream,
                mDetailsContainer, false);
        final ViewGroup livestreamsBlock = (ViewGroup) livestreamsCard
                .findViewById(R.id.card_livestreams_block);
        for (int i = 0; i < data.livestreams.length; i++) {
            if (data.livestreams[i].url == null) {
                continue;
            }
            final View livestreamItem = getLayoutInflater().inflate(R.layout.livestream_detail,
                    livestreamsBlock, false);
            final TextView livestreamNameView = (TextView) livestreamItem
                    .findViewById(R.id.livestream_name_view);
            final TextView livestreamServiceView = (TextView) livestreamItem
                    .findViewById(R.id.livestream_service_view);

            final Uri livestreamUri = Uri.parse(data.livestreams[i].url);

            livestreamNameView
                    .setText(data.livestreams[i].language.toUpperCase() + " - " + data.livestreams[i].title);
            livestreamServiceView
                    .setText(data.livestreams[i].url.contains("twitch.tv") ? "Twitch.tv" : "DailyMotion");

            livestreamItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent viewLivestreamIntent = new Intent(Intent.ACTION_VIEW, livestreamUri);
                    startActivity(viewLivestreamIntent);
                }
            });

            livestreamsBlock.addView(livestreamItem);

            final View divider = getLayoutInflater().inflate(R.layout.divider, livestreamsBlock, false);
            livestreamsBlock.addView(divider);
        }

        mDetailsContainer.addView(livestreamsCard, 1);

    }

    if (data.vods != null && data.vods.length != 0) {
        final ViewGroup vodsCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_vods,
                mDetailsContainer, false);
        final ViewGroup vodsBlock = (ViewGroup) vodsCard.findViewById(R.id.card_vods_block);
        for (int i = 0; i < data.vods.length; i++) {
            final TextView vodsItem = (TextView) getLayoutInflater().inflate(R.layout.vod_detail, vodsBlock,
                    false);

            vodsItem.setText(data.vods[i].vodDesc);

            final Uri vodUri = Uri.parse(data.vods[i].vodUrl);

            vodsItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent viewVodIntent = new Intent(Intent.ACTION_VIEW, vodUri);
                    startActivity(viewVodIntent);
                }
            });

            vodsBlock.addView(vodsItem);

            final View divider = getLayoutInflater().inflate(R.layout.divider, vodsBlock, false);
            vodsBlock.addView(divider);
        }

        mDetailsContainer.addView(vodsCard, 2);

    }

    data.teamOne.flagUrl = teamLeftFlagUrl;
    data.teamTwo.flagUrl = teamRightFlagUrl;
    data.teamOne.name = teamLeftName;
    data.teamTwo.name = teamRightName;

    mTeamCardOne = makeTeamView(data.teamOne, mDetailsContainer);
    mTeamCardTwo = makeTeamView(data.teamTwo, mDetailsContainer);

    mDetailsContainer.addView(mTeamCardOne);
    mDetailsContainer.addView(mTeamCardTwo);

    mMatchTeamOneImageView.setClickable(true);
    mMatchTeamTwoImageView.setClickable(true);

    mMatchTeamOneImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mScrollView.smoothScrollTo(0,
                    Math.round(mTeamCardOne.getY() + mTeamCardOne.getHeight() - mHeaderHeightPixels));
        }
    });

    mMatchTeamTwoImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mScrollView.smoothScrollTo(0,
                    Math.round(mTeamCardTwo.getY() + mTeamCardTwo.getHeight() - mHeaderHeightPixels));
        }
    });

    final ViewGroup extrasCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_links, mDetailsContainer,
            false);

    final ViewGroup extrasBlock = (ViewGroup) extrasCard.findViewById(R.id.card_links_block);

    final TextView extrasItem = (TextView) getLayoutInflater().inflate(R.layout.link_item, extrasBlock, false);

    extrasItem.setText("GosuGamers Match Page");

    extrasItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent viewGGNetMatchPage = new Intent(Intent.ACTION_VIEW, Uri.parse(mUrl));
            startActivity(viewGGNetMatchPage);
        }
    });

    extrasBlock.addView(extrasItem);

    mDetailsContainer.addView(extrasCard);

    mMatchViewContainer.setBackground(null);
    //getWindow().setBackgroundDrawable(null);

    mDetailsContainer.animate().translationY(0).setDuration(350).setInterpolator(new DecelerateInterpolator())
            .start();

}

From source file:com.box.myview.MyTopSnackBar.TSnackbar.java

/**
 * Set the action to be displayed in this {@link TSnackbar}.
 *
 * @param text     Text to display/*from   w  w  w.  j  a  va2 s .  c o  m*/
 * @param listener callback to be invoked when the action is clicked
 */
@NonNull
public TSnackbar setAction(CharSequence text, final View.OnClickListener listener) {
    final TextView tv = mView.getActionView();
    if (TextUtils.isEmpty(text) || listener == null) {
        tv.setVisibility(View.GONE);
        tv.setOnClickListener(null);
    } else {
        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:com.sft.blackcatapp.EnrollSchoolActivity.java

private void showPopupWindow(View parent) {
    if (popupWindow == null) {
        View view = View.inflate(mContext, R.layout.pop_window, null);

        TextView c1Car = (TextView) view.findViewById(R.id.pop_window_one);
        c1Car.setText(R.string.c1_automatic_gear_car);
        TextView c2Car = (TextView) view.findViewById(R.id.pop_window_two);
        c2Car.setText(R.string.c2_manual_gear_car);
        c1Car.setOnClickListener(this);
        c2Car.setOnClickListener(this);

        popupWindow = new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    }/*from w  w  w. java2  s . c o  m*/
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    // Back???
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    // WindowManager windowManager = (WindowManager)
    // getSystemService(Context.WINDOW_SERVICE);
    // int xPos = -popupWindow.getWidth() / 2
    // + getCustomTitle().getCenter().getWidth() / 2;

    popupWindow.showAsDropDown(parent);

}

From source file:com.me.resume.MainActivity.java

/**
 * ?//from  w ww. java2 s  .  c o m
 * @param view
 */
private void initView8(View view) {
    mViewList.add(view8);

    TextView words = (TextView) view8.findViewById(R.id.item2);
    String wordStr = preferenceUtil.getPreferenceData(Constants.MYWORDS, "");
    if (RegexUtil.checkNotNull(wordStr)) {
        words.setText(Html.fromHtml("&nbsp;&nbsp;" + wordStr));
    } else {
        words.setText(getResources().getString(R.string.resume_mywords));
    }

    words.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //            if (preferenceUtil.getPreferenceData(Constants.EDITMODE)) {
            goFlag = true;
            ActivityUtils.startActivity(self, Constants.PACKAGENAMECHILD + Constants.WORDS, false);
            //            }
        }
    });
    ImageView goHome = (ImageView) view8.findViewById(R.id.gohome);
    goHome.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            preferenceUtil.setPreferenceData(Constants.SET_STARTVERYTIME, false);
            ActivityUtils.startActivity(self, Constants.PACKAGENAMECHILD + Constants.HOME, true);
        }
    });
}

From source file:com.trukr.shipper.fragment.RequestStatus.java

private void showImageAlert() {
    dialogCamera = new Dialog(mContext);
    dialogCamera.requestWindowFeature(Window.FEATURE_NO_TITLE); //before
    dialogCamera.setContentView(R.layout.dialog_more_icon);
    dialogCamera.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialogCamera.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    dialogCamera.show();/*  ww  w  .ja v  a2  s  . c o  m*/
    TextView btnContact = (TextView) dialogCamera.findViewById(R.id.btnContact);
    TextView btnJobDetail = (TextView) dialogCamera.findViewById(R.id.btnJobDetail);
    TextView btnCancelOrder = (TextView) dialogCamera.findViewById(R.id.btnCancelOrder);
    TextView btnCancel = (TextView) dialogCamera.findViewById(R.id.btnCancel);

    /* Contact button click Method */
    btnContact.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialogCamera.dismiss();
            contactalertDialog(RequestStatus.this, IConstant.alert,
                    getResources().getString(R.string.contactalert));
        }
    });

    /* JobDetail button click Method */
    btnJobDetail.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialogCamera.dismiss();
            Intent intent = new Intent(RequestStatus.this, CurrentJobTabLayout.class);
            intent.putExtra("OrderId", orderId);
            startActivity(intent);
        }
    });

    /* CancelOrder button click Method */
    btnCancelOrder.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialogCamera.dismiss();
            cancelalertdialog(RequestStatus.this, IConstant.alert,
                    getResources().getString(R.string.cancelorder), StatusCode);

        }

    });
    /* Cancel button click Method */
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialogCamera.cancel();
        }
    });
}

From source file:com.frostwire.android.gui.activities.internal.NavigationMenu.java

private NavigationView initNavigationView(final MainActivity activity) {
    NavigationView resultNavView = navView;
    if (navView == null) {
        resultNavView = activity.findViewById(R.id.activity_main_nav_view);
        resultNavView.setNavigationItemSelectedListener(menuItem -> {
            onMenuItemSelected(menuItem);
            return true;
        });// ww  w .j a v  a 2  s  .c  o  m
        View navViewHeader = resultNavView.getHeaderView(0);
        // Logo
        ImageView navLogo = navViewHeader.findViewById(R.id.nav_view_header_main_app_logo);
        navLogo.setOnClickListener(v -> UIUtils.openURL(v.getContext(), Constants.FROSTWIRE_GIVE_URL));

        // Prep title and version
        TextView title = navViewHeader.findViewById(R.id.nav_view_header_main_title);
        TextView version = navViewHeader.findViewById(R.id.nav_view_header_main_version);
        String basicOrPlus = (String) activity
                .getText(Constants.IS_GOOGLE_PLAY_DISTRIBUTION ? R.string.basic : R.string.plus);
        boolean isDevelopment = Constants.IS_BASIC_AND_DEBUG;
        if (isDevelopment) {
            basicOrPlus = "Developer";
        }
        title.setText("FrostWire " + basicOrPlus);
        version.setText(" v" + Constants.FROSTWIRE_VERSION_STRING);
        TextView build = navViewHeader.findViewById(R.id.nav_view_header_main_build);
        build.setText(activity.getText(R.string.build) + " " + BuildConfig.VERSION_CODE);
        View.OnClickListener aboutActivityLauncher = v -> {
            Intent intent = new Intent(v.getContext(), AboutActivity.class);
            v.getContext().startActivity(intent);
        };
        title.setOnClickListener(aboutActivityLauncher);
        version.setOnClickListener(aboutActivityLauncher);
        build.setOnClickListener(aboutActivityLauncher);

        // Prep update button
        ImageView updateButton = navViewHeader.findViewById(R.id.nav_view_header_main_update);
        updateButton.setVisibility(View.GONE);
        updateButton.setOnClickListener(v -> onUpdateButtonClicked(activity));
    }
    return resultNavView;
}

From source file:com.sft.fragment.SchoolsFragment.java

private void showPopupWindow(View parent) {
    if (popupWindow == null) {
        View view = View.inflate(mContext, R.layout.pop_window, null);

        TextView c1Car = (TextView) view.findViewById(R.id.pop_window_one);
        c1Car.setText(R.string.c1_automatic_gear_car);
        TextView c2Car = (TextView) view.findViewById(R.id.pop_window_two);
        c2Car.setText(R.string.c2_manual_gear_car);
        TextView other = (TextView) view.findViewById(R.id.pop_window_three);
        other.setText(R.string.other);/*from www .j av a 2  s.com*/
        other.setOnClickListener(this);
        c1Car.setOnClickListener(this);
        c2Car.setOnClickListener(this);

        popupWindow = new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    }
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    // Back???
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    // WindowManager windowManager = (WindowManager)
    // getSystemService(Context.WINDOW_SERVICE);
    // int xPos = -popupWindow.getWidth() / 2
    // + getCustomTitle().getCenter().getWidth() / 2;

    popupWindow.showAsDropDown(parent);

}