android.widget.TextView#setClickable ( )源码实例Demo

下面列出了android.widget.TextView#setClickable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 365browser   文件: HyperlinkPreference.java
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    TextView titleView = (TextView) view.findViewById(android.R.id.title);
    titleView.setSingleLine(false);

    if (mImitateWebLink) {
        setSelectable(false);

        titleView.setClickable(true);
        titleView.setTextColor(titleView.getPaint().linkColor);
        titleView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                HyperlinkPreference.this.onClick();
            }
        });
    }
}
 
@Override
public View makeView() {
    TextView t = new TextView(mContext);
    t.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    t.setMaxLines(1);
    t.setPadding(mPadding, mPadding, mPadding, mPadding);
    t.setTextColor(textColor);
    t.setTextSize(mTextSize);

    t.setClickable(true);
    t.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (itemClickListener != null && textList.size() > 0 && currentId != -1) {
                itemClickListener.onItemClick(currentId % textList.size());
            }
        }
    });
    return t;
}
 
源代码3 项目: imsdk-android   文件: RobotItemAdapter.java
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LinearLayout lin = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.atom_ui_item_robot_tab, parent, false);
    final TextView textView = (TextView) lin.findViewById(R.id.content);
    final View line = lin.findViewById(R.id.line);
    Action item = (Action) getItem(position);
    if (position == 0) {
        line.setVisibility(View.INVISIBLE);
    }
    textView.setText(item.mainaction);
    textView.setTextSize(16);
    textView.setWidth(parent.getWidth() / getCount());
    textView.setFocusable(true);
    textView.setClickable(true);
    if (item.subactions != null && item.subactions.size() > 0) {
        Drawable drawable = context.getResources().getDrawable(R.drawable.atom_ui_has_child_action);
        if (drawable != null) {
            drawable.setBounds(10, 0, 20, 20);
            textView.setCompoundDrawables(drawable, null, null, null);
        }
    }
    return lin;
}
 
源代码4 项目: mappwidget   文件: TextPopup.java
public TextPopup(Context context, ViewGroup parentView) 
{
    super(context, parentView);
    
    text = new TextView(context);
    
    text.setPadding((int)(PADDING_LEFT * dipScaleFactor),
                    (int)(PADDING_TOP * dipScaleFactor),
                    (int)(PADDING_RIGHT  * dipScaleFactor), 
                    (int)(PADDING_BOTTOM * dipScaleFactor));
    
    text.setBackgroundResource(R.drawable.map_description_background);
    text.setTextSize(DEF_TEXT_SIZE);
    text.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
    text.setMaxEms(MAX_EMS);
    text.setTextColor(Color.WHITE);
    
    container.addView(text);

    text.setFocusable(true);
    text.setClickable(true);
}
 
源代码5 项目: prevent   文件: UserGuideActivity.java
private boolean setView(int id, String packageName) {
    TextView donate = (TextView) findViewById(id);
    PackageManager pm = getPackageManager();
    try {
        ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
        if (!info.enabled) {
            return false;
        }
        CharSequence label = getLabel(pm, info);
        donate.setContentDescription(label);
        donate.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(pm.getApplicationIcon(info)), null, null);
        donate.setText(label);
        donate.setClickable(true);
        donate.setOnClickListener(this);
        donate.setVisibility(View.VISIBLE);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        UILog.d("cannot find package " + packageName, e);
        return false;
    }
}
 
源代码6 项目: SEAL-Demo   文件: LearnMoreFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.learn_more_fragment, container, false);
    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.title_fragment_learn_more_page);
    mLeanMoreLink = (TextView) v.findViewById(R.id.learnMoreQuestion);
    mLeanMoreLink.setClickable(true);
    mLeanMoreLink.setMovementMethod(LinkMovementMethod.getInstance());
    String linkText = getString(R.string.learn_more_fragment_header_question)+" "
            + getString(R.string.learn_more_fragment_link_left) + URL + getString(R.string.learn_more_fragment_link_right);
    mLeanMoreLink.setText(Html.fromHtml(linkText));
    return v;
}
 
private TextView getEmptyTextView(Context context) {
    TextView textView = new TextView(context);
    textView.setClickable(false);
    textView.setGravity(Gravity.CENTER);
    GridLayout.LayoutParams params = new GridLayout.LayoutParams();
    params.setGravity(Gravity.FILL);
    params.rowSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
    params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);

    textView.setLayoutParams(params);

    return textView;
}
 
源代码8 项目: LaunchTime   文件: ColorChooser.java
private void makeColorPresetButton(int color) {
        FrameLayout outframe = new FrameLayout(getContext());
        outframe.setBackgroundColor(Color.BLACK);
        outframe.setPadding(6,6,6,6);

        FrameLayout frame = new FrameLayout(getContext());
        //frame.setPadding(6,6,6,6);
        //frame.setBackgroundColor(Color.BLACK);
        frame.setBackgroundResource(R.drawable.bwg);

        TextView c = new TextView(getContext());
        c.setText("   ");
        c.setTextSize(22);
        c.setBackgroundColor(color);
//        if (color==Color.TRANSPARENT) {
//            c.setBackgroundResource(R.drawable.transparentgrid);
//        }
        c.setTag(color);
        c.setClickable(true);
        c.setOnClickListener(setColorListener);
        frame.addView(c);
        GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
        lp.setMargins(24, 16, 24, 16);
        outframe.setPadding(6,6,6,6);
        outframe.addView(frame);
        colorPresets.addView(outframe, lp);
    }
 
源代码9 项目: TitleBar   文件: ViewCore.java
static TextView newRightView(Context context) {
    TextView rightView = new TextView(context);
    rightView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    rightView.setGravity(Gravity.CENTER_VERTICAL);
    rightView.setFocusable(true);
    rightView.setClickable(true);
    rightView.setSingleLine();
    rightView.setEllipsize(TextUtils.TruncateAt.END);
    return rightView;
}
 
源代码10 项目: Mobike   文件: DepositRefundIssueActivity.java
private void selectPayType(View view) {
    mTvWeixin.setBackgroundResource(R.color.bg_color);
    mTvAlipay.setBackgroundResource(R.color.bg_color);
    mTvWeixin.setTextColor(getResources().getColor(R.color.black));
    mTvAlipay.setTextColor(getResources().getColor(R.color.black));
    mTvWeixin.setClickable(true);
    mTvAlipay.setClickable(true);
    TextView tv = (TextView) view;
    tv.setBackgroundResource(R.color.red);
    tv.setClickable(false);
    tv.setTextColor(getResources().getColor(R.color.white));
    currentpaytype = Integer.valueOf((String) tv.getTag());
}
 
RunStopIndicatorPopupWindow(final DataWrapper dataWrapper, final Activity activity) {
    super(R.layout.popup_window_run_stop_indicator, R.string.editor_activity_targetHelps_trafficLightIcon_title, activity);

    // Disable default animation
    //setAnimationStyle(0);

    final TextView textView = popupView.findViewById(R.id.run_stop_indicator_popup_window_important_info);
    textView.setClickable(true);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intentLaunch = new Intent(activity, ImportantInfoActivity.class);
            intentLaunch.putExtra(ImportantInfoActivity.EXTRA_SHOW_QUICK_GUIDE, false);
            intentLaunch.putExtra(ImportantInfoActivity.EXTRA_SCROLL_TO, R.id.activity_info_notification_event_not_started);
            activity.startActivity(intentLaunch);

            dismiss();
        }
    });

    final SwitchCompat checkBox = popupView.findViewById(R.id.run_stop_indicator_popup_window_checkbox);
    checkBox.setChecked(Event.getGlobalEventsRunning());
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (dataWrapper != null)
                dataWrapper.runStopEventsWithAlert(activity, checkBox, isChecked);
        }
    });
}
 
源代码12 项目: Android-Commons   文件: UI.java
/**
 * Sets the given `TextView` to be read-only or read-and-write
 *
 * @param view a `TextView` or one of its subclasses
 * @param readOnly whether the view should be read-only or not
 */
public static void setReadOnly(final TextView view, final boolean readOnly) {
	view.setFocusable(!readOnly);
	view.setFocusableInTouchMode(!readOnly);
	view.setClickable(!readOnly);
	view.setLongClickable(!readOnly);
	view.setCursorVisible(!readOnly);
}
 
源代码13 项目: pandroid   文件: SnackbarManager.java
private ToastNotifier makeCustomNotification(Activity activity, ToastType toastType, String label, String btnLabel, int drawableRes, int style, int duration, boolean undefinedLoad, final ToastListener listener) {
    if (duration < 0)
        duration = Snackbar.LENGTH_INDEFINITE;
    final Snackbar notif = Snackbar.make(activity.findViewById(android.R.id.content), label, duration);
    if (style == 0) {
        style = R.style.Toast;
    }
    TypedArray attributes = activity.obtainStyledAttributes(style, R.styleable.ToastAppearance);
    int textColor = attributes.getColor(R.styleable.ToastAppearance_toastTextColor, ContextCompat.getColor(activity, R.color.white));
    int buttonTextColor = attributes.getColor(R.styleable.ToastAppearance_toastButtonTextColor, ContextCompat.getColor(activity, R.color.pandroid_green_dark));
    int backgroundColor = attributes.getColor(R.styleable.ToastAppearance_toastBackground, ContextCompat.getColor(activity, R.color.pandroid_green));
    notif.getView().setBackgroundColor(backgroundColor);
    ((TextView) notif.getView().findViewById(android.support.design.R.id.snackbar_text)).setTextColor(textColor);
    TextView actionView = ((TextView) notif.getView().findViewById(android.support.design.R.id.snackbar_action));
    actionView.setTextColor(buttonTextColor);
    attributes.recycle();

    notif.setCallback(new Snackbar.Callback() {
        @Override
        public void onDismissed(Snackbar snackbar, int event) {
            super.onDismissed(snackbar, event);
            if (listener != null)
                listener.onDismiss();
        }
    });

    Drawable drawable = null;
    if (drawableRes > 0) {
        drawable = ContextCompat.getDrawable(activity, drawableRes);
    }
    actionView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, drawable, null);
    if (toastType == ToastType.ACTION && btnLabel != null) {
        notif.setAction(btnLabel, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null)
                    listener.onActionClicked();
            }
        });
    } else if (drawableRes > 0) {
        actionView.setVisibility(View.VISIBLE);
        actionView.setClickable(false);
        actionView.setFocusableInTouchMode(false);
        actionView.setFocusable(false);
        actionView.setEnabled(false);
    }

    if (toastType == ToastType.LOADER) {
        ProgressWheel progressWheel = new ProgressWheel(activity);
        progressWheel.setId(R.id.snakebar_loader);
        if (undefinedLoad)
            progressWheel.spin();

        progressWheel.setBarWidth((int) DeviceUtils.dpToPx(activity, 4));
        progressWheel.setCircleRadius((int) DeviceUtils.dpToPx(activity, 30));
        progressWheel.setBarColor(buttonTextColor);
        progressWheel.setLinearProgress(true);
        ((Snackbar.SnackbarLayout) notif.getView()).addView(progressWheel, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }
    notif.show();
    lastShowNotif = notif;
    return new ToastNotifier() {
        @Override
        public void setProgress(int progress) {
            ProgressWheel loader = (ProgressWheel) notif.getView().findViewById(R.id.snakebar_loader);
            if (loader != null) {
                loader.setProgress(progress / 100f);
            }
        }

        @Override
        public void dismiss() {
            notif.dismiss();
        }

    };
}
 
源代码14 项目: douyin   文件: MainActivity.java
public void init(LinearLayout linearLayout1, CustomLinearLayout layout){

        ListView listView = new ListView(this);
        listView.setLayoutParams(new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT
        ));
        listView.setOnItemClickListener(this);
        InfoAdapter adapter = new InfoAdapter(this);
        adapter.setItems(getList());
        listView.setAdapter(adapter);

        linearLayout1.addView(listView);

        String[] colors = new String[]{"#417BC7", "#6FA13E", "#DB9548", "#C8382E", "#753B94"};
//        for (int i = 0; i < 10; i++){
//            CustomLabelTextView customLabelTextView = new CustomLabelTextView(
//                    this,
//                    "测试文字",
//                    "test"+i,
//                    "#58575c",
//                    CustomLabelTextView.randomColorString(colors));
//            layout.addView(customLabelTextView);
//        }
        initModel(layout);
        for (VersionEnum versionEnum : VersionEnum.values()){
            CustomLabelTextView customLabelTextView = new CustomLabelTextView(
                    this,
                    versionEnum.isSupported() ? "已支持版本" : "不支持版本",
                    versionEnum.getVersion(),
                    "#58575c",
                    CustomLabelTextView.randomColorString(colors));
            layout.addView(customLabelTextView);
        }

        TextView tv_left = new TextView(this);
        tv_left.setText("测试");
        tv_left.setTextColor(Color.WHITE);
        tv_left.setClickable(true);
        tv_left.setPadding(dp2px(10), dp2px(2), dp2px(10), dp2px(2));
        GradientDrawable drawable1 = ViewUtil.createGradientDrawableRadius(2, new float[]{14, 14, 0, 0, 0, 0, 14, 14}, Color.MAGENTA);
        drawable1.setColor(ViewUtil.createColorStateList(
                Color.parseColor("#58575c"),
                Color.parseColor("#ae58575c"),
                Color.parseColor("#58575c"),
                Color.parseColor("#a158575c")));
        tv_left.setBackground(drawable1);

        LinearLayout.LayoutParams tv_params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, dp2px(24));

        tv_left.setLayoutParams(tv_params);

        layout.addView(tv_left);


        PlusButton plusButton = new PlusButton(this);
        plusButton.setText("测试按钮");
        plusButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(MainActivity.this, "点击事件", Toast.LENGTH_SHORT).show();

                Intent intent = new Intent(MainActivity.this, TestActivity.class);
                MainActivity.this.startActivity(intent);
            }
        });
        layout.addView(plusButton);
    }
 
@Override
protected void onFinishInflate() {
    final int childCount = getChildCount();
    if (childCount > 2) {
        throw new IllegalStateException("PtrFrameLayout can only contains 2 children");
    } else if (childCount == 2) {
        if (mHeaderId != 0 && mHeaderView == null) {
            mHeaderView = findViewById(mHeaderId);
        }
        if (mContainerId != 0 && mContent == null) {
            mContent = findViewById(mContainerId);
        }

        // not specify header or content
        if (mContent == null || mHeaderView == null) {

            View child1 = getChildAt(0);
            View child2 = getChildAt(1);
            if (child1 instanceof PtrUIHandler) {
                mHeaderView = child1;
                mContent = child2;
            } else if (child2 instanceof PtrUIHandler) {
                mHeaderView = child2;
                mContent = child1;
            } else {
                // both are not specified
                if (mContent == null && mHeaderView == null) {
                    mHeaderView = child1;
                    mContent = child2;
                }
                // only one is specified
                else {
                    if (mHeaderView == null) {
                        mHeaderView = mContent == child1 ? child2 : child1;
                    } else {
                        mContent = mHeaderView == child1 ? child2 : child1;
                    }
                }
            }
        }
    } else if (childCount == 1) {
        mContent = getChildAt(0);
    } else {
        TextView errorView = new TextView(getContext());
        errorView.setClickable(true);
        errorView.setTextColor(0xffff6600);
        errorView.setGravity(Gravity.CENTER);
        errorView.setTextSize(20);
        errorView.setText("The content view in PtrFrameLayout is empty. Do you forget to specify its id in xml layout file?");
        mContent = errorView;
        addView(mContent);
    }
    if (mHeaderView != null) {
        mHeaderView.bringToFront();
    }
    super.onFinishInflate();
}
 
源代码16 项目: WheelView   文件: WheelViewDialog.java
private void init() {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(WheelUtils.dip2px(mContext, 20), 0, WheelUtils.dip2px(mContext, 20), 0);

    mTitle = new TextView(mContext);
    mTitle.setTextColor(WheelConstants.DIALOG_WHEEL_COLOR);
    mTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    mTitle.setGravity(Gravity.CENTER);
    LinearLayout.LayoutParams titleParams =
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            WheelUtils.dip2px(mContext, 50));
    layout.addView(mTitle, titleParams);

    mLine1 = new View(mContext);
    mLine1.setBackgroundColor(WheelConstants.DIALOG_WHEEL_COLOR);
    LinearLayout.LayoutParams lineParams =
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            WheelUtils.dip2px(mContext, 2));
    layout.addView(mLine1, lineParams);

    mWheelView = new WheelView(mContext);
    mWheelView.setSkin(WheelView.Skin.Holo);
    mWheelView.setWheelAdapter(new ArrayWheelAdapter(mContext));
    mStyle = new WheelView.WheelViewStyle();
    mStyle.textColor = Color.GRAY;
    mStyle.selectedTextZoom = 1.2f;
    mWheelView.setStyle(mStyle);

    mWheelView.setOnWheelItemSelectedListener((position, text) -> {
        mSelectedPos = position;
        mSelectedText = text;
    });
    ViewGroup.MarginLayoutParams wheelParams =
            new ViewGroup.MarginLayoutParams(LinearLayout.LayoutParams
            .MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    layout.addView(mWheelView, wheelParams);

    mLine2 = new View(mContext);
    mLine2.setBackgroundColor(WheelConstants.DIALOG_WHEEL_COLOR);
    LinearLayout.LayoutParams line2Params =
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            WheelUtils.dip2px(mContext, 1f));
    layout.addView(mLine2, line2Params);

    mButton = new TextView(mContext);
    mButton.setTextColor(WheelConstants.DIALOG_WHEEL_COLOR);
    mButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    mButton.setGravity(Gravity.CENTER);
    mButton.setClickable(true);
    mButton.setOnClickListener(this);
    mButton.setText("OK");
    LinearLayout.LayoutParams buttonParams =
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            WheelUtils.dip2px(mContext, 45));
    layout.addView(mButton, buttonParams);

    mDialog = new AlertDialog.Builder(mContext).create();
    mDialog.setView(layout);
    mDialog.setCanceledOnTouchOutside(false);
}
 
private void initializeView(Context context, AttributeSet attrs, int defStyleAttr) {
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.CenteredDrawableButton,
            defStyleAttr,
            0);

    Drawable drawableLeft = a.getDrawable(R.styleable.CenteredDrawableButton_drawableLeft);
    Drawable drawableRight = a.getDrawable(R.styleable.CenteredDrawableButton_drawableRight);
    Drawable drawableTop = a.getDrawable(R.styleable.CenteredDrawableButton_drawableTop);
    Drawable drawableBottom = a.getDrawable(R.styleable.CenteredDrawableButton_drawableBottom);
    int drawablePadding =
            a.getDimensionPixelSize(R.styleable.CenteredDrawableButton_drawablePadding, 0);

    CharSequence text = a.getText(R.styleable.CenteredDrawableButton_text);
    int textColor = a.getColor(R.styleable.CenteredDrawableButton_textColor, -1);
    ColorStateList textColorStateList =
            a.getColorStateList(R.styleable.CenteredDrawableButton_textColor);
    int textSize = a.getDimensionPixelSize(R.styleable.CenteredDrawableButton_textSize, 0);
    int textStyle = a.getInt(R.styleable.CenteredDrawableButton_textStyle, 0);

    textView = new TextView(context, attrs);
    textView.setDuplicateParentStateEnabled(true);
    textView.setClickable(false);
    textView.setText(text);
    textView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    if (textColor >= 0) {
        textView.setTextColor(textColor);
    }
    if (textColorStateList != null) {
        textView.setTextColor(textColorStateList);
    }
    if (textSize > 0) {
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    }
    textView.setCompoundDrawablesWithIntrinsicBounds(drawableLeft, drawableTop, drawableRight, drawableBottom);
    textView.setCompoundDrawablePadding(drawablePadding);
    Typeface tf = Typeface.defaultFromStyle(textStyle);
    textView.setTypeface(tf);
    RelativeLayout.LayoutParams params
            = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    textView.setLayoutParams(params);
    textView.setGravity(Gravity.CENTER_VERTICAL);
    addView(textView);

    a.recycle();
}
 
源代码18 项目: RIBs   文件: TicTacToeView.java
@Override
public void addCross(BoardCoordinate xy) {
  TextView textView = imageButtons[xy.getX()][xy.getY()];
  textView.setText("x");
  textView.setClickable(false);
}
 
源代码19 项目: LiveSourceCode   文件: PtrFrameLayout.java
@Override
protected void onFinishInflate() {
    final int childCount = getChildCount();
    if (childCount > 2) {
        throw new IllegalStateException("PtrFrameLayout can only contains 2 children");
    } else if (childCount == 2) {
        if (mHeaderId != 0 && mHeaderView == null) {
            mHeaderView = findViewById(mHeaderId);
        }
        if (mContainerId != 0 && mContent == null) {
            mContent = findViewById(mContainerId);
        }

        // not specify header or content
        if (mContent == null || mHeaderView == null) {

            View child1 = getChildAt(0);
            View child2 = getChildAt(1);
            if (child1 instanceof PtrUIHandler) {
                mHeaderView = child1;
                mContent = child2;
            } else if (child2 instanceof PtrUIHandler) {
                mHeaderView = child2;
                mContent = child1;
            } else {
                // both are not specified
                if (mContent == null && mHeaderView == null) {
                    mHeaderView = child1;
                    mContent = child2;
                }
                // only one is specified
                else {
                    if (mHeaderView == null) {
                        mHeaderView = mContent == child1 ? child2 : child1;
                    } else {
                        mContent = mHeaderView == child1 ? child2 : child1;
                    }
                }
            }
        }
    } else if (childCount == 1) {
        mContent = getChildAt(0);
    } else {
        TextView errorView = new TextView(getContext());
        errorView.setClickable(true);
        errorView.setTextColor(0xffff6600);
        errorView.setGravity(Gravity.CENTER);
        errorView.setTextSize(20);
        errorView.setText("The content view in PtrFrameLayout is empty. Do you forget to specify its id in xml layout file?");
        mContent = errorView;
        addView(mContent);
    }
    if (mHeaderView != null) {
        mHeaderView.bringToFront();
    }
    super.onFinishInflate();
}
 
源代码20 项目: materialup   文件: HtmlUtils.java
/**
 * Work around some 'features' of TextView and URLSpans. i.e. vanilla URLSpans do not react to
 * touch so we replace them with our own {@link io.plaidapp.ui.span
 * .TouchableUrlSpan}
 * & {@link io.plaidapp.util.LinkTouchMovementMethod} to fix this.
 * <p>
 * Setting a custom MovementMethod on a TextView also alters touch handling (see
 * TextView#fixFocusableAndClickableSettings) so we need to correct this.
 *
 * @param textView
 * @param input
 */
public static void setTextWithNiceLinks(TextView textView, CharSequence input) {
    textView.setText(input);
    textView.setMovementMethod(LinkTouchMovementMethod.getInstance());
    textView.setFocusable(false);
    textView.setClickable(false);
    textView.setLongClickable(false);
}
 
 方法所在类
 同类方法