Example usage for android.widget TextView setFocusableInTouchMode

List of usage examples for android.widget TextView setFocusableInTouchMode

Introduction

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

Prototype

public void setFocusableInTouchMode(boolean focusableInTouchMode) 

Source Link

Document

Set whether this view can receive focus while in touch mode.

Usage

From source file:com.android.tv.settings.dialog.DialogFragment.java

private void setContentView(View content) {
    TextView titleView = (TextView) content.findViewById(R.id.title);
    TextView breadcrumbView = (TextView) content.findViewById(R.id.breadcrumb);
    TextView descriptionView = (TextView) content.findViewById(R.id.description);
    titleView.setText(mTitle);/*from ww  w .  ja va2 s . co m*/
    breadcrumbView.setText(mBreadcrumb);
    descriptionView.setText(mDescription);
    final ImageView iconImageView = (ImageView) content.findViewById(R.id.icon);
    if (mIconBackgroundColor != Color.TRANSPARENT) {
        iconImageView.setBackgroundColor(mIconBackgroundColor);
    }

    if (AccessibilityHelper.forceFocusableViews(getActivity())) {
        titleView.setFocusable(true);
        titleView.setFocusableInTouchMode(true);
        descriptionView.setFocusable(true);
        descriptionView.setFocusableInTouchMode(true);
        breadcrumbView.setFocusable(true);
        breadcrumbView.setFocusableInTouchMode(true);
    }

    if (mIconResourceId != 0) {
        iconImageView.setImageResource(mIconResourceId);
        updateViewSize(iconImageView);
    } else {
        if (mIconBitmap != null) {
            iconImageView.setImageBitmap(mIconBitmap);
            updateViewSize(iconImageView);
        } else {
            if (mIconUri != null) {
                iconImageView.setVisibility(View.INVISIBLE);

                DrawableDownloader bitmapDownloader = DrawableDownloader.getInstance(content.getContext());
                mBitmapCallBack = new BitmapCallback() {
                    @Override
                    public void onBitmapRetrieved(Drawable bitmap) {
                        if (bitmap != null) {
                            mIconBitmap = (bitmap instanceof BitmapDrawable)
                                    ? ((BitmapDrawable) bitmap).getBitmap()
                                    : null;
                            iconImageView.setVisibility(View.VISIBLE);
                            iconImageView.setImageDrawable(bitmap);
                            updateViewSize(iconImageView);
                        }
                    }
                };

                bitmapDownloader.getBitmap(new BitmapWorkerOptions.Builder(content.getContext())
                        .resource(mIconUri).width(iconImageView.getLayoutParams().width).build(),
                        mBitmapCallBack);
            } else {
                iconImageView.setVisibility(View.GONE);
            }
        }
    }

    content.setTag(R.id.title, titleView);
    content.setTag(R.id.breadcrumb, breadcrumbView);
    content.setTag(R.id.description, descriptionView);
    content.setTag(R.id.icon, iconImageView);
}