Example usage for android.widget TextView setFocusable

List of usage examples for android.widget TextView setFocusable

Introduction

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

Prototype

public void setFocusable(boolean focusable) 

Source Link

Document

Set whether this view can receive the focus.

Usage

From source file:com.example.android.leanback.StringPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    Log.d(TAG, "onCreateViewHolder");
    final Context context = parent.getContext();
    TextView tv = new TextView(context);
    tv.setFocusable(true);
    tv.setFocusableInTouchMode(true);//w  ww.j  ava  2s  .  c o  m
    tv.setBackground(
            ResourcesCompat.getDrawable(context.getResources(), R.drawable.text_bg, context.getTheme()));
    return new ViewHolder(tv);
}

From source file:com.scooter1556.sms.android.presenter.SettingsItemPresenter.java

@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);//  w  ww  .jav a  2 s.  c  o m
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.primary));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}

From source file:com.scooter1556.sms.androidtv.presenter.MediaFolderPresenter.java

@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);//www . j ava  2  s. c o m
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}

From source file:dk.moerks.ratebeermobile.Rate.java

@Override
protected void onStart() {
    super.onStart();
    TextView beernameText = (TextView) findViewById(R.id.rate_label_beername);
    beernameText.setFocusable(true);
    beernameText.setFocusableInTouchMode(true);
    beernameText.requestFocus();//from   w  w w  . ja v a 2  s  .co  m

}

From source file:com.rukiasoft.androidapps.cocinaconroll.ui.ToolbarAndRefreshActivity.java

public void setToolbar(Toolbar toolbar) {
    setSupportActionBar(toolbar);//w  w  w  .j  a  v a 2 s  .c  o  m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    try {
        if (toolbar.getClass() != null) {
            Field f = toolbar.getClass().getDeclaredField("mTitleTextView");
            f.setAccessible(true);
            TextView titleTextView = (TextView) f.get(toolbar);
            titleTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            titleTextView.setFocusable(true);
            titleTextView.setFocusableInTouchMode(true);
            titleTextView.requestFocus();
            titleTextView.setSingleLine(true);
            titleTextView.setSelected(true);
            titleTextView.setMarqueeRepeatLimit(-1);
        }
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.autoparts.buyers.view.viewpagerindicator.TabPageMessageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    //        final TabView tabView = new TabView(getContext());
    //        tabView.mIndex = index;
    //        tabView.setFocusable(true);
    //        tabView.setOnClickListener(mTabClickListener);
    //        tabView.setText(text);
    ///*from   w w  w .  j a  v  a  2s  . c o m*/
    //        if (iconResId != 0) {
    //            tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
    //        }
    View view = LayoutInflater.from(context).inflate(R.layout.tab_page_view, null);
    TextView textView = (TextView) view.findViewById(R.id.tab_page_textView);

    textView.setFocusable(true);
    textView.setOnClickListener(mTabClickListener);
    textView.setText(text);
    mTabLayout.addView(view, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
}

From source file:com.google.android.leanbackjank.presenter.GridItemPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());

    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);//  w ww .  j  a  v a  2  s  .c o m
    view.setBackgroundColor(ResourcesCompat.getColor(parent.getResources(), R.color.jank_yellow, null));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.view.survey.SurveyInteractionView.java

@Override
public void doOnCreate(final Activity activity, Bundle savedInstanceState) {

    if (savedInstanceState != null) {
        surveySubmitted = savedInstanceState.getBoolean(KEY_SURVEY_SUBMITTED, false);
    }/*from   w  w  w  .  j  a  va  2s .  c  om*/

    if (interaction == null || surveySubmitted) {
        activity.finish();
        return;
    }

    activity.setContentView(R.layout.apptentive_survey);

    // Hide branding if needed.
    final View branding = activity.findViewById(R.id.apptentive_branding_view);
    if (branding != null) {
        if (Configuration.load(activity).isHideBranding(activity)) {
            branding.setVisibility(View.GONE);
        }
    }

    TextView title = (TextView) activity.findViewById(R.id.title);
    title.setFocusable(true);
    title.setFocusableInTouchMode(true);
    title.setText(interaction.getName());

    String descriptionText = interaction.getDescription();
    if (descriptionText != null) {
        TextView description = (TextView) activity.findViewById(R.id.description);
        description.setText(descriptionText);
        description.setVisibility(View.VISIBLE);
    }

    final Button send = (Button) activity.findViewById(R.id.send);
    send.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Util.hideSoftKeyboard(activity, view);
            surveySubmitted = true;
            if (interaction.isShowSuccessMessage() && interaction.getSuccessMessage() != null) {
                SurveyThankYouDialog dialog = new SurveyThankYouDialog(activity);
                dialog.setMessage(interaction.getSuccessMessage());
                dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        activity.finish();
                    }
                });
                dialog.show();
            } else {
                activity.finish();
            }

            EngagementModule.engageInternal(activity, interaction, EVENT_SUBMIT, data.toString());
            ApptentiveDatabase.getInstance(activity).addPayload(new SurveyResponse(interaction, surveyState));
            Log.d("Survey Submitted.");
            callListener(true);

            cleanup();
        }
    });

    LinearLayout questions = (LinearLayout) activity.findViewById(R.id.questions);
    questions.removeAllViews();

    // Then render all the questions
    for (final Question question : interaction.getQuestions()) {
        if (question.getType() == Question.QUESTION_TYPE_SINGLELINE) {
            TextSurveyQuestionView textQuestionView = new TextSurveyQuestionView(activity, surveyState,
                    (SinglelineQuestion) question);
            textQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() {
                public void onAnswered() {
                    sendMetricForQuestion(activity, question);
                    send.setEnabled(isSurveyValid());
                }
            });
            questions.addView(textQuestionView);
        } else if (question.getType() == Question.QUESTION_TYPE_MULTICHOICE) {
            MultichoiceSurveyQuestionView multichoiceQuestionView = new MultichoiceSurveyQuestionView(activity,
                    surveyState, (MultichoiceQuestion) question);
            multichoiceQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() {
                public void onAnswered() {
                    sendMetricForQuestion(activity, question);
                    send.setEnabled(isSurveyValid());
                }
            });
            questions.addView(multichoiceQuestionView);
        } else if (question.getType() == Question.QUESTION_TYPE_MULTISELECT) {
            MultiselectSurveyQuestionView multiselectQuestionView = new MultiselectSurveyQuestionView(activity,
                    surveyState, (MultiselectQuestion) question);
            multiselectQuestionView.setOnSurveyQuestionAnsweredListener(new OnSurveyQuestionAnsweredListener() {
                public void onAnswered() {
                    sendMetricForQuestion(activity, question);
                    send.setEnabled(isSurveyValid());
                }
            });
            questions.addView(multiselectQuestionView);
        }
    }

    send.setEnabled(isSurveyValid());

    // Force the top of the survey to be shown first.
    title.requestFocus();
}

From source file:com.aengbee.android.leanback.presenter.GridItemPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());

    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);//from w w w . j av  a2  s  .c o  m
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}

From source file:ecust.news.myWidgetTabPageIndicator.java

public TextView decorateTextView(TextView textView) {
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, Global.dimenConvert.dip2px(20));
    textView.setSingleLine();//ww w  . j  a va 2 s  . c om
    textView.setTextColor(textViewUnfocusedColor);
    textView.setFocusable(true);
    textView.setClickable(true);

    //Padding
    final int paddingLeftRight = Global.dimenConvert.dip2px(12);
    final int paddingTop = Global.dimenConvert.dip2px(8);
    final int paddingBottom = Global.dimenConvert.dip2px(0);
    textView.setPadding(paddingLeftRight, paddingTop, paddingLeftRight, paddingBottom);

    return textView;
}