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

The following are Jave code examples for showing how to use setFocusable() 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: FamilyLibraryManager   File: DetailsActivity.java   View Source Code Vote up 8 votes
private void getBook(Intent intent) {
    String bookId = intent.getStringExtra("bookId");
    Double price = intent.getDoubleExtra("price", 0.00);
    TextView bookIdTextView = (TextView) findViewById(bookNumberEditText);
    bookIdTextView.setText(bookId);bookIdTextView.setFocusable(false);
    TextView bookNameTextView = (TextView) findViewById(bookNameEditText);
    bookNameTextView.setText(intent.getStringExtra("bookName"));
    TextView typeTextView = (TextView) findViewById(bookTypeEditText);
    typeTextView.setText(intent.getStringExtra("type"));
    TextView authorTextView = (TextView) findViewById(bookAuthorEditText);
    authorTextView.setText(intent.getStringExtra("author"));
    TextView priceTextView = (TextView) findViewById(bookPriceEditText);
    priceTextView.setText(price.toString());
    TextView borrowerTextView = (TextView) findViewById(R.id.bookBorrowerEditText);
    borrowerTextView.setText(intent.getStringExtra("borrower"));
    TextView publicationDateTextView = (TextView) findViewById(R.id.bookDateEditText);
    publicationDateTextView.setText(intent.getStringExtra("publicationDate"));
}
 
Example 2
Project: NeuTV   File: TabStrip.java   View Source Code Vote up 6 votes
/**
 * 添加指示器
 *
 * @param position
 * @param title
 */
private void addTab(final int position, CharSequence title) {
    TextView tvTab = new TextView(context);
    tvTab.setText(title);
    tvTab.setTextColor(textColor);
    tvTab.setTextSize(textSize);
    tvTab.setGravity(Gravity.CENTER);
    if(isIndicatorTextBold){
        TextPaint tp = tvTab.getPaint();
        tp.setFakeBoldText(true);
    }
    tvTab.setSingleLine();
    tvTab.setFocusable(true);
    tvTab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            viewPager.setCurrentItem(position);
        }
    });
    tvTab.setPadding(indicatorMargin, 0, indicatorMargin, 0);
    container.addView(tvTab, position, expandedTabLayoutParams);
}
 
Example 3
Project: open-rmbt   File: RMBTTermsCheckFragment.java   View Source Code Vote up 6 votes
@Override
public void onResume()
{
    super.onResume();
    final Activity activity = getActivity();
    final boolean tcAccepted = ConfigHelper.isTCAccepted(activity);
    if (tcAccepted)
    {
        final TextView buttonTermsAccept = (TextView) view.findViewById(R.id.termsAcceptButton);
        buttonTermsAccept.setFocusable(true); //set focus on button so that terms can be accepted on Android TV like devices (5-way-navigation)
        buttonTermsAccept.setFocusableInTouchMode(false);
        buttonTermsAccept.requestFocus();
        buttonTermsAccept.setText(R.string.terms_accept_button_continue);
        view.findViewById(R.id.termsAcceptText).setVisibility(View.GONE);
    }
}
 
Example 4
Project: MTweaks-KernelAdiutorMOD   File: DescriptionFragment.java   View Source Code Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_description, container, false);

    mTitleView = (TextView) rootView.findViewById(R.id.title);
    mSummaryView = (TextView) rootView.findViewById(R.id.summary);

    if (Utils.isTv(getActivity())) {
        mSummaryView.setFocusable(true);
    } else {
        mTitleView.setTextIsSelectable(true);
        mSummaryView.setTextIsSelectable(true);
    }

    mSummaryView.setSelected(true);
    mSummaryView.setMovementMethod(LinkMovementMethod.getInstance());

    mTitle = getArguments().getCharSequence("title");
    mSummary = getArguments().getCharSequence("summary");

    refresh();
    return rootView;
}
 
Example 5
Project: KernelAdiutor-Mod   File: DescriptionFragment.java   View Source Code Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_description, container, false);

    mTitleView = (TextView) rootView.findViewById(R.id.title);
    mSummaryView = (TextView) rootView.findViewById(R.id.summary);

    if (Utils.isTv(getActivity())) {
        mSummaryView.setFocusable(true);
    } else {
        mTitleView.setTextIsSelectable(true);
        mSummaryView.setTextIsSelectable(true);
    }

    mSummaryView.setSelected(true);
    mSummaryView.setMovementMethod(LinkMovementMethod.getInstance());

    mTitle = getArguments().getCharSequence("title");
    mSummary = getArguments().getCharSequence("summary");

    refresh();
    return rootView;
}
 
Example 6
Project: SelectName   File: SelectActivity.java   View Source Code Vote up 6 votes
private void initView() {

        btnSave = (Button) findViewById(R.id.btnSave);
        btnSave.setOnClickListener(this);
        btndel = (Button) findViewById(R.id.btndel);
        btndel.setOnClickListener(this);
        btnupdate = (Button) findViewById(R.id.btnupdate);
        btnupdate.setOnClickListener(this);
        btnQuery = (Button) findViewById(R.id.btnQuery);
        btnQuery.setOnClickListener(this);
        tvTextView = (TextView) findViewById(R.id.tv);
        tvTextView.setFocusable(true);

        etFirstName = (AppCompatEditText) findViewById(R.id.etFirstName);
        etFirstName.setOnClickListener(this);
        btn_back = (ImageView) findViewById(R.id.btn_back);
        btn_back.setOnClickListener(this);
    }
 
Example 7
Project: CXJPadProject   File: DishesView.java   View Source Code Vote up 6 votes
private View getcontentTextView() {

        countText=new TextView(getContext());

        countText.setSingleLine(true);
        countText.setGravity(Gravity.CENTER);
        countText.setMaxEms(8);
        countText.setTextSize(20);
        countText.setFocusable(false);
        LayoutParams param=getLayoutParams((getMeasuredWidth()-20)/4,getMeasuredHeight()+80);
        param.weight=3;
        param.gravity= Gravity.CENTER;
        countText.setLayoutParams(param);

        setBackgroundDrawable(countText, editTextDrawable);
//        onUpdateEditText();
        onUpdatecountText();

        return countText;
    }
 
Example 8
Project: OSchina_resources_android   File: CommentsUtil.java   View Source Code Vote up 6 votes
@SuppressWarnings("deprecation")
public static void formatHtml(Resources resources, TextView textView, String str) {
    if (str == null)
        return;
    str = str.trim();

    textView.setMovementMethod(MyLinkMovementMethod.a());
    textView.setFocusable(false);
    textView.setClickable(false);
    textView.setLongClickable(false);

    if (textView instanceof TweetTextView) {
        ((TweetTextView) textView).setDispatchToParent(true);
    }

    str = TweetTextView.modifyPath(str);
    Spanned span = Html.fromHtml(str);
    span = InputHelper.displayEmoji(resources, span.toString());
    textView.setText(span);
    MyURLSpan.parseLinkText(textView, span);
}
 
Example 9
Project: PlusGram   File: SlidingTabView.java   View Source Code Vote up 6 votes
public void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextColor(0xffffffff);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    tab.setTypeface(Typeface.DEFAULT_BOLD);
    tab.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false));

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            didSelectTab(position);
        }
    });
    addView(tab);
    LayoutParams layoutParams = (LayoutParams)tab.getLayoutParams();
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.width = 0;
    layoutParams.weight = 50;
    tab.setLayoutParams(layoutParams);

    tabCount++;
}
 
Example 10
Project: DizzyPassword   File: SearchView.java   View Source Code Vote up 6 votes
private void initData(String[] mVals) {

        for (int i = 0; i < mVals.length; i++) {

            tv = (TextView) mInflater.inflate(
                    R.layout.search_label_tv, mFlowLayout, false);
            tv.setTextColor(getResources().getColor(R.color.cardview_dark_background));
            tv.setText(mVals[i]);
            tv.setClickable(true);
            tv.setFocusable(true);
            mFlowLayout.addView(tv);
            final String str = tv.getText().toString().trim();
            tv.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View view) {
                    String string = etSearch.getText().toString().trim();
                    etSearch.setText(string + " " + str);
                }
            });

        }
    }
 
Example 11
Project: DizzyPassword   File: SearchView.java   View Source Code Vote up 6 votes
private void initDataByName(String[] mVals) {

        for (int i = 0; i < mVals.length; i++) {

            tv = (TextView) mInflater.inflate(
                    R.layout.search_label_tv, mFlowLayout_name, false);
            tv.setTextColor(getResources().getColor(R.color.cardview_dark_background));
            tv.setText(mVals[i]);
            tv.setClickable(true);
            tv.setFocusable(true);
            mFlowLayout_name.addView(tv);
            final String str = tv.getText().toString().trim();
            tv.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View view) {
                    String string = etSearch.getText().toString().trim();
                    etSearch.setText(string + " " + str);
                }
            });

        }
    }
 
Example 12
Project: HelloTV   File: MainFragment.java   View Source Code Vote up 5 votes
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(getResources().getColor(R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
Example 13
Project: airgram   File: SlidingTabView.java   View Source Code Vote up 5 votes
public void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setTypeface(FontManager.instance().getTypeface());
    tab.setText(title);
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextColor(0xffffffff);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    tab.setTypeface(Typeface.DEFAULT_BOLD);
    tab.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, false));

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            didSelectTab(position);
        }
    });
    addView(tab);
    LayoutParams layoutParams = (LayoutParams)tab.getLayoutParams();
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.width = 0;
    layoutParams.weight = 50;
    tab.setLayoutParams(layoutParams);

    tabCount++;
}
 
Example 14
Project: tubik   File: MainFragment.java   View Source Code Vote up 5 votes
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(getResources().getColor(R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
Example 15
Project: leanback-extensions   File: MainFragment.java   View Source Code Vote up 5 votes
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
	TextView view = new TextView(parent.getContext());
	view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT));
	view.setFocusable(true);
	view.setFocusableInTouchMode(true);
	view.setBackgroundColor(getResources().getColor(R.color.default_background));
	view.setTextColor(Color.WHITE);
	view.setGravity(Gravity.CENTER);
	return new ViewHolder(view);
}
 
Example 16
Project: chilly   File: GridItemPresenter.java   View Source Code Vote up 5 votes
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {

    mDefaultBackgroundColor =
            ContextCompat.getColor(parent.getContext(), R.color.default_background);
    mSelectedBackgroundColor =
            ContextCompat.getColor(parent.getContext(), R.color.selected_background);

    TextView view = new AppCompatTextView(parent.getContext()) {
        @Override
        public void setSelected(boolean selected) {
            updateGridItemBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.grid_item_width);
    int height = res.getDimensionPixelSize(R.dimen.grid_item_height);

    view.setLayoutParams(new ViewGroup.LayoutParams(width, height));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(),
            R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
Example 17
Project: cleaninsights-android-sdk   File: MainFragment.java   View Source Code Vote up 5 votes
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(getResources().getColor(R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
Example 18
Project: OSchina_resources_android   File: Tweet.java   View Source Code Vote up 5 votes
public void setLikeUsers(Context contet, TextView likeUser, boolean limit) {
    // 构造多个超链接的html, 通过选中的位置来获取用户名
    if (getLikeCount() > 0 && getLikeUser() != null
            && !getLikeUser().isEmpty()) {
        likeUser.setVisibility(View.VISIBLE);
        likeUser.setMovementMethod(LinkMovementMethod.getInstance());
        likeUser.setFocusable(false);
        likeUser.setLongClickable(false);
        likeUser.setText(addClickablePart(contet, limit), BufferType.SPANNABLE);
    } else {
        likeUser.setVisibility(View.GONE);
        likeUser.setText("");
    }
    likeUser.setVisibility(View.GONE);
}
 
Example 19
Project: EpisodeListView   File: ChildrenAdapter.java   View Source Code Vote up 4 votes
public MyViewHolder(View view) {
    super(view);
    textView = (TextView) view.findViewById(R.id.item);
    textView.setFocusable(true);
}
 
Example 20
Project: chromium-for-android-56-debug-video   File: FloatLabelLayout.java   View Source Code Vote up 4 votes
public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setOrientation(VERTICAL);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
            dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingRight,
            dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding = a.getDimensionPixelSize(
            R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
            dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    mLabel.setFocusable(true);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    ApiCompatibilityUtils.setTextAppearance(mLabel,
            a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
                    android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
                ? android.R.interpolator.fast_out_slow_in
                : android.R.anim.decelerate_interpolator);
}