Java Code Examples for android.widget.TextView.setOnClickListener()

The following are Jave code examples for showing how to use setOnClickListener() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Robust   File: SecondActivity.java   View Source Code Vote up 6 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        listView = (ListView) findViewById(R.id.listview);
        TextView textView = (TextView) findViewById(R.id.secondtext);
        textView.setOnClickListener(v -> {
//                    RobustModify.modify();
                    Log.d("robust", " onclick  in Listener");
                }
        );
        //change text on the  SecondActivity
        textView.setText(getTextInfo());

        //test array
        BaseAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_expandable_list_item_1, multiArr);
        listView.setAdapter(adapter);
    }
 
Example 2
Project: Plus1s   File: LostViewActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lost_view);

    final TextView lost_view_back = (TextView) findViewById(R.id.lost_view_back);
    lost_view_list = (ListView) findViewById(R.id.lost_view_list);
    final Animation fade_in_anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in);
    lost_view_list.setAnimation(fade_in_anim);
    ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, displayLostItem());
    lost_view_list.setAdapter(adapter);
    lost_view_back.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            goToMain();
        }
    });
}
 
Example 3
Project: GCSApp   File: ExpandableTextView2.java   View Source Code Vote up 6 votes
/**
 * 初始化viwe
 */
private void findViews() {
    LayoutInflater inflater = (LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.item_expand_collapse, this);
    mTvContent = (TextView) findViewById(R.id.expandable_text);
    mTvContent.setOnClickListener(this);
    mTvExpandCollapse = (TextView) findViewById(R.id.expand_collapse);
    setDrawbleAndText();
    mTvExpandCollapse.setOnClickListener(this);

    mTvContent.setTextColor(contentTextColor);
    mTvContent.getPaint().setTextSize(contentTextSize);

    mTvExpandCollapse.setTextColor(collapseExpandTextColor);
    mTvExpandCollapse.getPaint().setTextSize(collapseExpandTextSize);

    //设置收起展开位置:左或者右
    LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.gravity = grarity;
    mTvExpandCollapse.setLayoutParams(lp);
}
 
Example 4
Project: decoy   File: BlackListActivity.java   View Source Code Vote up 6 votes
private void initActionbar() {
    TextView toolbarView = findView(R.id.action_bar_right_clickable_textview);
    toolbarView.setText(R.string.add);
    toolbarView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ContactSelectActivity.Option option = new ContactSelectActivity.Option();
            option.title = "选择黑名单";
            option.maxSelectNum = 1;
            ArrayList<String> excludeAccounts = new ArrayList<>();
            for (UserInfoProvider.UserInfo user : data) {
                if (user != null) {
                    excludeAccounts.add(user.getAccount());
                }
            }
            option.itemFilter = new ContactIdFilter(excludeAccounts, true);
            NimUIKit.startContactSelect(BlackListActivity.this, option, REQUEST_CODE_BLACK);
        }
    });
}
 
Example 5
Project: DailyStudy   File: SimpleViewPagerIndicator.java   View Source Code Vote up 6 votes
private void generateTitleView() {
    if (getChildCount() > 0)
        this.removeAllViews();
    int count = mTitles.length;

    setWeightSum(count);
    for (int i = 0; i < count; i++) {
        TextView tv = new TextView(getContext());
        LayoutParams lp = new LayoutParams(0, LayoutParams.MATCH_PARENT);
        lp.weight = 1;
        tv.setGravity(Gravity.CENTER);
        tv.setTextColor(COLOR_TEXT_NORMAL);
        tv.setText(mTitles[i]);
        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
        tv.setLayoutParams(lp);
        tv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        addView(tv);
    }
}
 
Example 6
Project: Review-   File: CreateTableActivity.java   View Source Code Vote up 6 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create_table);
        initToolBar();
        showOrHideToolBarNavigation(true);
//        initData();
        mBtCreateTable = (TextView) findViewById(R.id.bt_create);
        mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
        mBtCreateTable.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mProgressBar.setProgress(0);
                initData();
            }
        });
    }
 
Example 7
Project: DarkCalculator   File: CapitalMoneyActivity.java   View Source Code Vote up 5 votes
private void initTextOut() {
    textOut = (TextView) findViewById(R.id.text_out);
    AutofitHelper.create(textOut).setMaxLines(6);
    textOut.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ClipboardManager cmb = (ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
            cmb.setText(textOut.getText());
            Snackbar.make(v, "已复制转换结果", Snackbar.LENGTH_SHORT).show();
        }
    });
}
 
Example 8
Project: TestChat   File: UrlTextView.java   View Source Code Vote up 5 votes
private void initView() {
        setOrientation(VERTICAL);
        LayoutInflater.from(getContext()).inflate(R.layout.share_fragment_item_content_layout, this);
        contentText = (TextView) findViewById(R.id.tv_url_text_content);
        contentText.setTextSize(PixelUtil.dp2px(16));
        contentText.setTextColor(getResources().getColor(R.color.base_color_text_black));
        cover = (TextView) findViewById(R.id.tv_url_text_cover);
        cover.setTextColor(getResources().getColor(R.color.base_color_text_black));
        contentText.setMaxLines(maxLine);
        cover.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                        if (cover.getText().toString().trim().equals("全文")) {
                                contentText.setMaxLines(Integer.MAX_VALUE);
                                cover.setText("收起");
                                if (mOnTextExpandStatusChangeListener != null) {
                                        mOnTextExpandStatusChangeListener.onExpandStatusChanged(false);
                                }
                        } else if (cover.getText().toString().trim().equals("收起")) {
                                contentText.setMaxLines(maxLine);
                                cover.setText("全文");
                                if (mOnTextExpandStatusChangeListener != null) {
                                        mOnTextExpandStatusChangeListener.onExpandStatusChanged(true);
                                }
                        }
                }
        });
}
 
Example 9
Project: Samantha   File: TicketViewHolder.java   View Source Code Vote up 5 votes
public void bindData(InfoBean bean) {

        TextView tvSetting = (TextView) findViewByResName(bean.type().ui().resNameEdit(), "id");
        if (tvSetting != null) {
            tvSetting.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                }
            });
        }

        if (bean.type().id().matches("1[0-9]*")) {
            tvDetailTitle.setText("火车票");
        }

        for (ConceptDesc description : bean.type().conceptDescs()) {
            String resName = description.identifier();
            String defType = description.resType();
            if (resName != null) {
                TextView tv = (TextView) findViewByResName(resName, defType);
                String value = bean.valueOfConcept(description.concept());
                if (tv != null && value != null) {
                    tv.setText(value);
                } else {
                    if (tv != null) {
                        tv.setVisibility(View.INVISIBLE);
                    }
                    if (tvSetting != null) {
                        tvSetting.setVisibility(View.VISIBLE);
                    }
                }
                if (description.concept().id() == 1) {
                    tvDetailTitleContent.setText(value);
                }
            }
        }
    }
 
Example 10
Project: Guanajoven   File: AcercaDeFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_acerca_de, parent, false);

    textViewLineasAccion = (TextView) v.findViewById(R.id.enlace_lineas_de_accion);
    textViewDiagnosticoJuvenil = (TextView) v.findViewById(R.id.enlace_diagnostico_juvenil);
    textViewEncuestaJuventud = (TextView) v.findViewById(R.id.enlace_encuesta_de_juventud);
    textViewDirectorio = (TextView) v.findViewById(R.id.enlace_directorio);

    textViewLineasAccion.setOnClickListener((View) -> {
        enlace(getString(R.string.fragment_acercade_link_lineas_accion));
    });

    textViewDiagnosticoJuvenil.setOnClickListener((View) -> {
        enlace(getString(R.string.fragment_acercade_link_diagnostico));
    });

    textViewEncuestaJuventud.setOnClickListener((View) -> {
        enlace(getString(R.string.fragment_acerdade_link_encuesta));
    });

    textViewDirectorio.setOnClickListener((View) -> {
        enlace(getString(R.string.fragment_acercade_link_directorio));
    });

    return v;
}
 
Example 11
Project: yyox   File: DialogBox.java   View Source Code Vote up 5 votes
/**
 * 显示对话框
 */
@SuppressLint("InflateParams")
public void show() {

    mainView.removeAllViews();
    if (!TextUtils.isEmpty(title)) {
        mainView.addView(dialogTitle);
        dialogTitle.setVisibility(View.VISIBLE);
        dialogTitle.setText(title);
    }
    if (!TextUtils.isEmpty(message)) {
        mainView.addView(dialogText);
        dialogText.setVisibility(View.VISIBLE);
        dialogText.setText(message);
    }
    if (listView != null) {
        mainView.addView(listView);
    }
    //只创建了一个按钮
    if (btnNames.size() == 1) {
        singleBtn = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.kf5_message_box_single_btn, null);
        TextView dialogBtn = (TextView) singleBtn.findViewById(R.id.kf5_dialogBtn);
        dialogBtn.setText(btnNames.get(0));
        dialogBtn.setOnClickListener(new ClickListener(0));
        mainView.addView(singleBtn);
    } else if (btnNames.size() == 2) {
        doubleBtn = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.kf5_message_box_double_btn, null);
        TextView leftBtn = (TextView) doubleBtn.findViewById(R.id.kf5_dialogLeftBtn);
        TextView rightBtn = (TextView) doubleBtn.findViewById(R.id.kf5_dialogRightBtn);
        leftBtn.setText(btnNames.get(0));
        leftBtn.setOnClickListener(new ClickListener(0));
        rightBtn.setText(btnNames.get(1));
        rightBtn.setOnClickListener(new ClickListener(1));
        mainView.addView(doubleBtn);
    }
    dialog.setContentView(mainView);
    dialog.show();

}
 
Example 12
Project: NeiHanDuanZiTV   File: AlertView.java   View Source Code Vote up 5 votes
protected void initActionSheetViews(LayoutInflater layoutInflater) {
    ViewGroup viewGroup = (ViewGroup) layoutInflater.inflate(R.layout.layout_alertview_actionsheet,contentContainer);
    initHeaderView(viewGroup);

    initListView();
    TextView tvAlertCancel = (TextView) contentContainer.findViewById(R.id.tvAlertCancel);
    if(cancel != null){
        tvAlertCancel.setVisibility(View.VISIBLE);
        tvAlertCancel.setText(cancel);
    }
    tvAlertCancel.setOnClickListener(new OnTextClickListener(CANCELPOSITION));
}
 
Example 13
Project: BBSSDK-for-Android   File: EmptyView.java   View Source Code Vote up 5 votes
private void init(Context context) {
	tvEmpty = new TextView(context);
	int tvEmptySize = getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_empty_view_txt_size"));
	tvEmpty.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvEmptySize);
	int padding = ResHelper.dipToPx(context, 10);
	tvEmpty.setPadding(padding, padding, padding, padding);
	int tvEmptyColor = getResources().getColor(ResHelper.getColorRes(context, "bbs_empty_view_txt_color"));
	tvEmpty.setTextColor(tvEmptyColor);
	tvEmpty.setId(ResHelper.getIdRes(context, "tvEmpty"));

	ivEmpty = new ImageView(context);
	ivEmpty.setScaleType(ImageView.ScaleType.CENTER);

	LayoutParams rlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	rlp.addRule(CENTER_IN_PARENT, TRUE);
	addView(tvEmpty, rlp);

	rlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	rlp.addRule(CENTER_HORIZONTAL, TRUE);
	rlp.addRule(ABOVE, tvEmpty.getId());
	addView(ivEmpty, rlp);

	OnClickListener ocl = new OnClickListener() {
		public void onClick(View view) {
			tvEmpty.setClickable(false);
			ivEmpty.setClickable(false);
			if (onRefreshClickListener != null) {
				onRefreshClickListener.onClick(view);
			}
		}
	};
	tvEmpty.setClickable(false);
	ivEmpty.setClickable(false);
	tvEmpty.setOnClickListener(ocl);
	ivEmpty.setOnClickListener(ocl);
}
 
Example 14
Project: EosCommander   File: InputDataDialog.java   View Source Code Vote up 5 votes
@Override
protected void setUpView(View view) {
    TextView tv;
    String initialData;
    Bundle args = getArguments();
    mWalletName = args.getString( ARG_WALLET_NAME );
    mInputType  = Type.safeValueOf( args.getString( ARG_INPUT_TYPE));
    initialData = args.getString( ARG_INITIAL_INPUT_DATA );

    // title
    tv = view.findViewById( R.id.tv_title);
    tv.setText( getString(mInputType.titleStrId) + ": " + mWalletName);

    // input data
    mEtData = view.findViewById(R.id.et_input_data);

    // input data hint
    mEtData.setHint( mInputType.inputHintStrId );

    // initial data
    if ( ! StringUtils.isEmpty( initialData )) {
        UiUtils.setTextAndMoveCursorToEnd( mEtData, initialData);
    }

    // ok button
    tv = view.findViewById( R.id.btn_ok);
    tv.setText( mInputType.okButtonStrId);
    tv.setOnClickListener( v -> {
        if ( null != mCallback) mCallback.onDataEntered( mWalletName, mEtData.getText().toString());

        dismiss();
    });

    // cancel button
    view.findViewById( R.id.btn_cancel).setOnClickListener( v -> dismiss());
}
 
Example 15
Project: AppTycoon   File: AppTycoonDialog.java   View Source Code Vote up 4 votes
private void setActionTextViewListener(TextView view, View.OnClickListener listener) {
    view.setOnTouchListener(new TextViewChangeColourOnTouchListener(Color.BLACK,
            view.getCurrentTextColor()));
    view.setOnClickListener(listener);
}
 
Example 16
Project: lqrwechatrongcloud   File: EditPageLand.java   View Source Code Vote up 4 votes
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = ResHelper.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_multi_share");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvShare = new TextView(activity);
	tvShare.setTextColor(0xffff6d11);
	tvShare.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvShare.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_share");
	if (resId > 0) {
		tvShare.setText(resId);
	}
	tvShare.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvShare, lp);
	tvShare.setOnClickListener(this);
}
 
Example 17
Project: civify-app   File: UserAttacher.java   View Source Code Vote up 4 votes
public UserAttacher setFullName(@NonNull TextView fullName) {
    fullName.setText(mUser.getFullName());
    fullName.setOnClickListener(mShowProfile);
    return this;
}
 
Example 18
Project: Android-Code-Demos   File: NerdLauncherFragment.java   View Source Code Vote up 4 votes
public ActivityHolder(View itemView) {
    super(itemView);
    mNameTextView = (TextView) itemView;
    mNameTextView.setOnClickListener(this);
}
 
Example 19
Project: LQRWeChat   File: EditPageLand.java   View Source Code Vote up 4 votes
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = ResHelper.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_multi_share");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvShare = new TextView(activity);
	tvShare.setTextColor(0xffff6d11);
	tvShare.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvShare.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_share");
	if (resId > 0) {
		tvShare.setText(resId);
	}
	tvShare.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvShare, lp);
	tvShare.setOnClickListener(this);
}
 
Example 20
Project: POCenter   File: FriendListPage.java   View Source Code Vote up 4 votes
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = ResHelper.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_contacts");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvConfirm = new TextView(activity);
	tvConfirm.setTextColor(0xffff6d11);
	tvConfirm.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvConfirm.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_confirm");
	if (resId > 0) {
		tvConfirm.setText(resId);
	}
	tvConfirm.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvConfirm, lp);
	tvConfirm.setOnClickListener(this);
}