List of usage examples for android.view View requestFocus
public final boolean requestFocus()
From source file:com.alivenet.dmvtaxi.fragment.FragmentArriveDriver.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (view != null) { ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) parent.removeView(view);/*from ww w.ja va 2 s. c om*/ } try { view = inflater.inflate(R.layout.fragment_time_estemet, container, false); } catch (InflateException e) { } if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } mPref = getActivity().getSharedPreferences(MYPREF, Context.MODE_PRIVATE); mUserId = mPref.getString("userId", null); gps = new GPSTracker(getActivity()); MyApplication.arrivedrivermarker = true; progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage("Please wait..."); progressDialog.setCancelable(false); mlinerlayoutbottom = (LinearLayout) view.findViewById(R.id.ll_bottom); mphone = (ImageView) view.findViewById(R.id.iv_phone); mphonenumber = (TextView) view.findViewById(R.id.tv_phonenumber); marrivaltime = (TextView) view.findViewById(R.id.tv_textarrival); mname = (TextView) view.findViewById(R.id.tv_name); mlicence = (TextView) view.findViewById(R.id.tv_licence); mtaximodel = (TextView) view.findViewById(R.id.tv_model); muserImage = (ImageView) view.findViewById(R.id.imageView_close); getLatLong(); btnSplite = (Button) view.findViewById(R.id.btn_splite_rides); btnSplite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(getActivity(), SplitAddFrnd.class); startActivity(in); } }); mphone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String uri = "tel:" + mphonenumber.getText().toString().trim(); Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse(uri)); startActivity(intent); } }); System.out.println("userId>>>>>>>>>>>>>>>>>>>>>" + mUserId); mname.setText(MyApplication.driverName); mlicence.setText(MyApplication.licenseId); mtaximodel.setText(MyApplication.vehicle); mphonenumber.setText(MyApplication.mobileNO); Picasso.with(getActivity()).load(MyApplication.imageUrl).error(R.mipmap.avtar).placeholder(R.mipmap.avtar) .into(muserImage); System.out.println("driverImageurl" + "chceck=" + MyApplication.imageUrl); mphonenumber.setText("Call To" + " " + MyApplication.driverName); final SinchClient sinchClient = Sinch.getSinchClientBuilder().context(getActivity()).userId(mUserId) .applicationKey("3b013f09-db1f-422e-ac7b-c6498e119612") .applicationSecret("LMhelEFYtUqms55VX1C7MQ==").environmentHost("sandbox.sinch.com").build(); sinchClient.setSupportCalling(true); sinchClient.start(); mphone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (call == null) { if (MyApplication.mobileNO != null && !MyApplication.mobileNO.equals("")) { call = sinchClient.getCallClient().callPhoneNumber("+" + MyApplication.mobileNO); System.out.println("mobile_number" + MyApplication.mobileNO); //call = sinchClient.getCallClient().callPhoneNumber("+918510834641"); try { call.addCallListener(new SinchCallListener()); } catch (Exception e) { e.printStackTrace(); } mphonenumber.setText("Hang Up"); } } else { call.hangup(); } } }); view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { // handle back button's click listener if (keyCode == KeyEvent.KEYCODE_BACK) { Fragment homeFragment = new FragmentMainScreen(); FragmentManager frgManager; frgManager = getFragmentManager(); frgManager.beginTransaction().replace(R.id.fragment_switch, homeFragment).commit(); return true; } return true; } return false; } }); return view; }
From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java
/** * Arrow scroll./*from w w w . jav a2 s .c om*/ * * @param direction the direction * @return true, if successful */ public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) currentFocused = null; boolean handled = false; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { handled = nextFocused.requestFocus(); } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }
From source file:info.staticfree.android.units.Units.java
public boolean onTouch(View v, MotionEvent event) { switch (v.getId()) { // this is used to prevent the first touch on these editors from triggering the IME soft keyboard. case R.id.want: case R.id.have: if (event.getAction() == MotionEvent.ACTION_DOWN) { final EditText editor = (EditText) v; if (v.hasFocus()) { editor.setInputType(defaultInputType); v.requestFocus(); return false; }//ww w .j a va2s . c om editor.setInputType(InputType.TYPE_NULL); } } return false; }
From source file:ucr.cs180.rlifts.DriverRegistration.java
private void attemptDriverRegister() { if (mAuthTask != null) { return;//from w w w. j a v a2s. c o m } mcarcolorview.setError(null); mcarmodelview.setError(null); mcarbrandview.setError(null); mcaryearview.setError(null); mdriverslicenseview.setError(null); mlicenseplateview.setError(null); mstateview.setError(null); String car_color = mcarcolorview.getText().toString(); String car_model = mcarmodelview.getText().toString(); String car_brand = mcarbrandview.getText().toString(); String car_year = mcaryearview.getText().toString(); String drivers_license = mdriverslicenseview.getText().toString(); String license_plate = mlicenseplateview.getText().toString(); String drive_state = mstateview.getText().toString(); boolean cancel = false; View focusView = null; if (TextUtils.isEmpty(car_color)) { mcarcolorview.setError("This field is required"); focusView = mcarcolorview; cancel = true; } if (TextUtils.isEmpty(car_model)) { mcarmodelview.setError("This field is required"); focusView = mcarmodelview; cancel = true; } if (TextUtils.isEmpty(car_year)) { mcaryearview.setError("This field is required"); focusView = mcaryearview; cancel = true; } if (TextUtils.isEmpty(drivers_license)) { mdriverslicenseview.setError("This field is required"); focusView = mdriverslicenseview; cancel = true; } if (TextUtils.isEmpty(license_plate)) { mlicenseplateview.setError("This field is required"); focusView = mlicenseplateview; cancel = true; } if (TextUtils.isEmpty(drive_state)) { mstateview.setError("This field is required"); focusView = mstateview; cancel = true; } if (cancel) { focusView.requestFocus(); } else { mAuthTask = new registerDriver(car_brand, car_model, car_year, car_color, drivers_license, license_plate, drive_state, DriverRegistration.this); mAuthTask.execute((Void) null); waitDialog = new HomeActivity.MySpinnerDialog(); String tag = "Waiting on registerDriver"; waitDialog.show(getSupportFragmentManager(), tag); } }
From source file:com.Bhailal_Chauhan.retailapp.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_about, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }//from w ww . jav a 2s. com if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8347337366")); startActivity(callIntent); } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bhailalchauhan.com/")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hibhailal458@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:com.hitesh_sahu.retailapp.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_about, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }//from ww w . ja v a2s .com if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8888813275")); startActivity(callIntent); } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://hiteshsahu.com/")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hiteshkrsahu@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:ayushi.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_about, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }//from www . jav a 2 s. c om if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8888813275")); startActivity(callIntent); } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://hiteshsahu.com/")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "hiteshkumarsahu1990@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:course1778.mobileapp.safeMedicare.Main.FamMemFrag.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //ListView listView = (ListView) view.findViewById(R.id.list_view); SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), R.layout.fam_mem_frag, current, new String[] { DatabaseHelper.TITLE, //String.format(format, DatabaseHelper.TIME_H), DatabaseHelper.TIME_H, //String.format(format, DatabaseHelper.TIME_M)}, DatabaseHelper.TIME_M }, new int[] { R.id.title, R.id.time_h, R.id.time_m }, 0); setListAdapter(adapter);/*from w ww . j av a 2 s. com*/ //listView.setAdapter(adapter); // if (current == null) { db = new DatabaseHelper(getActivity()); dbInteraction = new DatabaseInteractionHelper(getActivity()); task = new LoadCursorTask().execute(); // } view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent intent = new Intent(getActivity().getApplicationContext(), WelcomePage.class); startActivity(intent); return true; } else { return false; } } }); }
From source file:com.trupti_prajapati.retailapp.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_contactus, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }/* w ww .j ava 2 s . c o m*/ if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8866685640")); startActivity(callIntent); } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/truptinprajapati")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "truptiprajapati19@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:fr.unix_experience.owncloud_sms.activities.LoginActivity.java
/** * Attempts to sign in or register the account specified by the login form. * If there are form errors (invalid email, missing fields, etc.), the * errors are presented and no actual login attempt is made. *//*from w w w . j ava 2 s . c o m*/ public void attemptLogin() { if (mAuthTask != null) { return; } // Reset errors. _loginView.setError(null); _passwordView.setError(null); // Store values at the time of the login attempt. String protocol = _protocolView.getSelectedItem().toString(); String login = _loginView.getText().toString(); String password = _passwordView.getText().toString(); String serverAddr = _serverView.getText().toString(); boolean cancel = false; View focusView = null; // Check for a valid server address. if (TextUtils.isEmpty(protocol)) { cancel = true; } // Check for a valid server address. if (TextUtils.isEmpty(serverAddr)) { _serverView.setError(getString(R.string.error_field_required)); focusView = _loginView; cancel = true; } // Check for a valid login address. if (TextUtils.isEmpty(login)) { _loginView.setError(getString(R.string.error_field_required)); focusView = _loginView; cancel = true; } // Check for a valid password if (TextUtils.isEmpty(password)) { _passwordView.setError(getString(R.string.error_field_required)); focusView = _passwordView; cancel = true; } if (!isPasswordValid(password)) { _passwordView.setError(getString(R.string.error_invalid_password)); focusView = _passwordView; cancel = true; } if (cancel) { // There was an error; don't attempt login and focus the first // form field with an error. // reset the button progress _signInButton.setProgress(0); if (focusView != null) { focusView.requestFocus(); } } else { // Show a progress spinner, and kick off a background task to // perform the user login attempt. _signInButton.setProgress(25); showProgress(true); String serverURL = protocol + serverAddr; mAuthTask = new UserLoginTask(serverURL, login, password); mAuthTask.execute((Void) null); } }