List of usage examples for android.widget TextView requestFocus
public final boolean requestFocus()
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);/* ww w .j av a 2 s .c o m*/ beernameText.setFocusableInTouchMode(true); beernameText.requestFocus(); }
From source file:com.rukiasoft.androidapps.cocinaconroll.ui.ToolbarAndRefreshActivity.java
public void setToolbar(Toolbar toolbar) { setSupportActionBar(toolbar);/* ww w. j a v a2s .c om*/ 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.androzic.waypoint.WaypointDetails.java
@SuppressLint("NewApi") private void updateWaypointDetails(double lat, double lon) { Androzic application = Androzic.getApplication(); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.getSupportActionBar().setTitle(waypoint.name); View view = getView();//from w ww .j a v a 2 s. c om final TextView coordsView = (TextView) view.findViewById(R.id.coordinates); coordsView.requestFocus(); coordsView.setTag(Integer.valueOf(StringFormatter.coordinateFormat)); coordsView.setText(StringFormatter.coordinates(" ", waypoint.latitude, waypoint.longitude)); coordsView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int format = ((Integer) coordsView.getTag()).intValue() + 1; if (format == 5) format = 0; coordsView.setText(StringFormatter.coordinates(format, " ", waypoint.latitude, waypoint.longitude)); coordsView.setTag(Integer.valueOf(format)); } }); if (waypoint.altitude != Integer.MIN_VALUE) { ((TextView) view.findViewById(R.id.altitude)) .setText("\u2336 " + StringFormatter.elevationH(waypoint.altitude)); view.findViewById(R.id.altitude).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.altitude).setVisibility(View.GONE); } if (waypoint.proximity > 0) { ((TextView) view.findViewById(R.id.proximity)) .setText("~ " + StringFormatter.distanceH(waypoint.proximity)); view.findViewById(R.id.proximity).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.proximity).setVisibility(View.GONE); } double dist = Geo.distance(lat, lon, waypoint.latitude, waypoint.longitude); double bearing = Geo.bearing(lat, lon, waypoint.latitude, waypoint.longitude); bearing = application.fixDeclination(bearing); String distance = StringFormatter.distanceH(dist) + " " + StringFormatter.angleH(bearing); ((TextView) view.findViewById(R.id.distance)).setText(distance); ((TextView) view.findViewById(R.id.waypointset)).setText(waypoint.set.name); if (waypoint.date != null) { view.findViewById(R.id.date_row).setVisibility(View.VISIBLE); ((TextView) view.findViewById(R.id.date)) .setText(DateFormat.getDateFormat(activity).format(waypoint.date) + " " + DateFormat.getTimeFormat(activity).format(waypoint.date)); } else { view.findViewById(R.id.date_row).setVisibility(View.GONE); } if ("".equals(waypoint.description)) { view.findViewById(R.id.description_row).setVisibility(View.GONE); } else { WebView description = (WebView) view.findViewById(R.id.description); String descriptionHtml; try { TypedValue tv = new TypedValue(); Theme theme = activity.getTheme(); Resources resources = getResources(); theme.resolveAttribute(android.R.attr.textColorPrimary, tv, true); int secondaryColor = resources.getColor(tv.resourceId); String css = String.format( "<style type=\"text/css\">html,body{margin:0;background:transparent} *{color:#%06X}</style>\n", (secondaryColor & 0x00FFFFFF)); descriptionHtml = css + waypoint.description; description.setWebViewClient(new WebViewClient() { @SuppressLint("NewApi") @Override public void onPageFinished(WebView view, String url) { view.setBackgroundColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) view.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); } }); description.setBackgroundColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) description.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); } catch (Resources.NotFoundException e) { description.setBackgroundColor(Color.LTGRAY); descriptionHtml = waypoint.description; } WebSettings settings = description.getSettings(); settings.setDefaultTextEncodingName("utf-8"); settings.setAllowFileAccess(true); Uri baseUrl = Uri.fromFile(new File(application.dataPath)); description.loadDataWithBaseURL(baseUrl.toString() + "/", descriptionHtml, "text/html", "utf-8", null); view.findViewById(R.id.description_row).setVisibility(View.VISIBLE); } }
From source file:net.idlesoft.android.apps.github.activities.Repository.java
public void loadRepoInfo() { try {//from w ww.ja v a 2 s . c o m // TextView title = // (TextView)findViewById(R.id.tv_top_bar_title); // title.setText(m_jsonData.getString("name")); final TextView repo_name = (TextView) findViewById(R.id.tv_repository_info_name); repo_name.setText(mJson.getString("name")); repo_name.requestFocus(); final TextView repo_desc = (TextView) findViewById(R.id.tv_repository_info_description); repo_desc.setText(mJson.getString("description")); final TextView repo_owner = (TextView) findViewById(R.id.tv_repository_info_owner); repo_owner.setText(mJson.getString("owner")); final TextView repo_watcher_count = (TextView) findViewById(R.id.tv_repository_info_watchers); if (mJson.getInt("watchers") == 1) { repo_watcher_count.setText(mJson.getInt("watchers") + " watcher"); } else { repo_watcher_count.setText(mJson.getInt("watchers") + " watchers"); } final TextView repo_fork_count = (TextView) findViewById(R.id.tv_repository_info_forks); if (mJson.getInt("forks") == 1) { repo_fork_count.setText(mJson.getInt("forks") + " fork"); } else { repo_fork_count.setText(mJson.getInt("forks") + " forks"); } final TextView repo_website = (TextView) findViewById(R.id.tv_repository_info_website); if (mJson.getString("homepage") != "") { repo_website.setText(mJson.getString("homepage")); } else { repo_website.setText("N/A"); } /* Make the repository owner text link to his/her profile */ repo_owner.setMovementMethod(LinkMovementMethod.getInstance()); final Spannable spans = (Spannable) repo_owner.getText(); final ClickableSpan clickSpan = new ClickableSpan() { @Override public void onClick(final View widget) { final Intent i = new Intent(Repository.this, Profile.class); try { i.putExtra("username", mJson.getString("owner")); } catch (final JSONException e) { e.printStackTrace(); } startActivity(i); } }; spans.setSpan(clickSpan, 0, spans.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } catch (final JSONException e) { e.printStackTrace(); } ((Button) findViewById(R.id.btn_repository_info_branches)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, BranchesList.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("repo_owner", mRepositoryOwner); startActivity(intent); } }); ((Button) findViewById(R.id.btn_repository_info_issues)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, Issues.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("repo_owner", mRepositoryOwner); startActivity(intent); } }); ((Button) findViewById(R.id.btn_repository_info_network)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, NetworkList.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("username", mRepositoryOwner); startActivity(intent); } }); }
From source file:net.lp.actionbarpoirot.helpers.ActivityHelperHoneycomb.java
/** {@inheritDoc} */ @Override//from w w w . j av a2 s. c om public void enableActionBarTitleMarquee() { // Make title scrolling, a bit of a hack final TextView titleView = (TextView) mActivity.findViewById(actionBarTitleResId); if (titleView != null) { titleView.setEllipsize(TextUtils.TruncateAt.MARQUEE); titleView.setMarqueeRepeatLimit(-1); titleView.setFocusable(true); titleView.setFocusableInTouchMode(true); titleView.requestFocus();// TODO: action bar title doesn't keep // scrolling after you've touched // something else. Should fix that. } // Also focus LeftNavBar, a bit of a hack too final View view = (mActivity.findViewById(leftNavActionBarResId)); if (view != null) { view.setFocusable(true); view.setFocusableInTouchMode(true); view.requestFocus(); } }
From source file:com.kaszubski.kamil.emmhelper.MainActivity.java
private void longTextTitleMode(boolean enabled) { try {/* w w w. ja v a 2s. c o m*/ Field titleField = Toolbar.class.getDeclaredField("mTitleTextView"); titleField.setAccessible(enabled); TextView barTitleView = (TextView) titleField.get(toolbar); barTitleView.setEllipsize(enabled ? TextUtils.TruncateAt.START : TextUtils.TruncateAt.START); barTitleView.setFocusable(enabled); barTitleView.setFocusableInTouchMode(enabled); barTitleView.requestFocus(); barTitleView.setSingleLine(enabled); barTitleView.setSelected(enabled); } catch (NoSuchFieldException e) { Log.e(TAG, "" + e); } catch (IllegalAccessException e) { Log.e(TAG, " " + e); } }
From source file:org.rm3l.ddwrt.mgmt.AbstractRouterMgmtDialogFragment.java
private boolean validateForm(@NotNull AlertDialog d) { @NotNull//from w ww . jav a2s . co m final EditText ipAddrView = (EditText) d.findViewById(R.id.router_add_ip); final Editable ipAddrViewText = ipAddrView.getText(); if (!(Patterns.IP_ADDRESS.matcher(ipAddrViewText).matches() || Patterns.DOMAIN_NAME.matcher(ipAddrViewText).matches())) { displayMessage(getString(R.string.router_add_dns_or_ip_invalid) + ":" + ipAddrViewText, ALERT); ipAddrView.requestFocus(); openKeyboard(ipAddrView); return false; } boolean validPort; @NotNull final EditText portView = (EditText) d.findViewById(R.id.router_add_port); try { final String portStr = portView.getText().toString(); validPort = (!isNullOrEmpty(portStr) && (Integer.parseInt(portStr) > 0)); } catch (@NotNull final Exception e) { e.printStackTrace(); validPort = false; } if (!validPort) { displayMessage(getString(R.string.router_add_port_invalid) + ":" + portView.getText(), ALERT); portView.requestFocus(); openKeyboard(portView); return false; } @NotNull final EditText sshUsernameView = (EditText) d.findViewById(R.id.router_add_username); if (isNullOrEmpty(sshUsernameView.getText().toString())) { displayMessage(getString(R.string.router_add_username_invalid), ALERT); sshUsernameView.requestFocus(); openKeyboard(sshUsernameView); return false; } final int checkedAuthMethodRadioButtonId = ((RadioGroup) d.findViewById(R.id.router_add_ssh_auth_method)) .getCheckedRadioButtonId(); if (checkedAuthMethodRadioButtonId == R.id.router_add_ssh_auth_method_password) { //Check password @NotNull final EditText sshPasswordView = (EditText) d.findViewById(R.id.router_add_password); if (isNullOrEmpty(sshPasswordView.getText().toString())) { displayMessage(getString(R.string.router_add_password_invalid), ALERT); sshPasswordView.requestFocus(); openKeyboard(sshPasswordView); return false; } } else if (checkedAuthMethodRadioButtonId == R.id.router_add_ssh_auth_method_privkey) { //Check privkey @NotNull final TextView sshPrivKeyView = (TextView) d.findViewById(R.id.router_add_privkey_path); if (isNullOrEmpty(sshPrivKeyView.getText().toString())) { displayMessage(getString(R.string.router_add_privkey_invalid), ALERT); sshPrivKeyView.requestFocus(); return false; } } return true; }
From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java
public void handleRegisteredFbLogin(View v) throws ClientProtocolException, JSONException, IOException { TextView fbUsername = (TextView) textEntryView.findViewById(R.id.facebookLogin_email); TextView fbPassword = (TextView) textEntryView.findViewById(R.id.facebookLogin_password); TextView errorMessage = (TextView) textEntryView.findViewById(R.id.errorMessage); String userName = fbUsername.getText().toString(), password = fbPassword.getText().toString(); Log.i(tag, "userName: " + userName + " ,password: " + password); mPhone = mPhoneEdit.getText().toString(); if (!Text.isEmail(userName)) { errorMessage.setText("Please enter a valid email"); fbUsername.requestFocus(); return;/* w ww .j ava2 s . c o m*/ } JSONObject response = new Cloud(getApplicationContext(), userName, password) .loginWithFacebook(countryCode + mPhone, fbId); Log.i(tag, "reponse: " + response); Log.i(tag, "message value: " + response.getString("message")); if (response.getString("message").trim().length() == 0) { mUsername = userName; mPassword = password; finishLogin(); } else { errorMessage.setText(response.getString("message")); } }
From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java
private TextView initializeTextView() { final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final TextView textView = (TextView) inflater.inflate(R.layout.actionbar_title, null); textView.setFocusable(true);/*from w ww. j a v a 2 s. c o m*/ textView.setFocusableInTouchMode(true); textView.setSelected(true); textView.requestFocus(); return textView; }
From source file:universe.constellation.orion.viewer.OrionViewerActivity.java
public void updatePageSeeker() { SeekBar pageSeek = (SeekBar) findMyViewById(R.id.page_picker_seeker); pageSeek.setProgress(controller.getCurrentPage()); TextView view = (TextView) findMyViewById(R.id.page_picker_message); view.setText("" + (controller.getCurrentPage() + 1)); view.clearFocus();/*from w ww. j av a 2s .c o m*/ view.requestFocus(); }