List of usage examples for android.widget TextView setFocusableInTouchMode
public void setFocusableInTouchMode(boolean focusableInTouchMode)
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);/*from w w w . j av a 2 s . c o m*/ tv.setFocusableInTouchMode(true); 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);/*from w w w.j ava 2s.c o m*/ view.setFocusableInTouchMode(true); 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);/*from ww w. j a v a 2 s . c o m*/ 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); }
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);/*from w w w . j av a 2s .c om*/ beernameText.setFocusableInTouchMode(true); beernameText.requestFocus(); }
From source file:com.rukiasoft.androidapps.cocinaconroll.ui.ToolbarAndRefreshActivity.java
public void setToolbar(Toolbar toolbar) { setSupportActionBar(toolbar);//from w ww .ja va 2s.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:au.org.ala.fielddata.mobile.SurveyBuilder.java
public void buildSurveyName(Survey survey, ViewGroup parent) { ViewGroup row = (ViewGroup) viewContext.getLayoutInflater().inflate(R.layout.survey_layout, parent); TextView name = (TextView) row.findViewById(R.id.surveyName); name.setText(survey.name);/*from ww w.j av a 2 s . co m*/ name.setFocusableInTouchMode(true); name.setFocusable(true); TextView description = (TextView) row.findViewById(R.id.surveyDescription); description.setText(survey.description); }
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);/*from w ww .jav a 2 s.c o m*/ view.setFocusableInTouchMode(true); 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 ww.ja v a2 s . c o m*/ 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);/* w w w .ja v a2s. c om*/ 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); }
From source file:com.example.samsungmdm.MainActivity.java
public void onServerResponse(String response) { TextView serverResponseTextView = new TextView(this); serverResponseTextView.setHorizontallyScrolling(true); serverResponseTextView.setSingleLine(); serverResponseTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE); serverResponseTextView.setFocusableInTouchMode(true); serverResponseTextView.setMarqueeRepeatLimit(1); serverResponseTextView.setFocusable(true); String myTime = java.text.DateFormat.getTimeInstance().format(Calendar.getInstance().getTime()); serverResponseTextView.setText(myTime + " - " + response); mServerResponseLinearLayout.addView(serverResponseTextView, 0); //Parsing server response try {/*from w w w . ja v a2 s . co m*/ parseServerResponse(new JSONObject(response)); } catch (JSONException e) { Log.e(TAG, "Invalid JSON response from the server"); e.printStackTrace(); } }