List of usage examples for android.widget ScrollView setFocusableInTouchMode
public void setFocusableInTouchMode(boolean focusableInTouchMode)
From source file:Main.java
public static void disableAutoScrollToBottom(ScrollView scrollView) { scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); scrollView.setFocusable(true);/* w ww . j a v a 2 s . c om*/ scrollView.setFocusableInTouchMode(true); scrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { arg0.requestFocusFromTouch(); return false; } }); }
From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Random r=new Random(); // int uniqueNumber =(r.nextInt(999) + 100); // uniqueId = Integer.toString(uniqueNumber); // ?uniqueId//from w ww. j a v a 2s .c o m UUID uuid = UUID.randomUUID(); uniqueId = uuid.toString(); this.inflater = inflater; rootView = inflater.inflate(R.layout.fragment_car_check_basic_info, container, false); // <editor-fold defaultstate="collapsed" desc="??View?"> tableLayout = (TableLayout) rootView.findViewById(R.id.bi_content_table); contentLayout = (LinearLayout) rootView.findViewById(R.id.brand_input); Button vinButton = (Button) rootView.findViewById(R.id.bi_vin_button); vinButton.setOnClickListener(this); brandOkButton = (Button) rootView.findViewById(R.id.bi_brand_ok_button); brandOkButton.setEnabled(false); brandOkButton.setOnClickListener(this); brandSelectButton = (Button) rootView.findViewById(R.id.bi_brand_select_button); brandSelectButton.setEnabled(false); brandSelectButton.setOnClickListener(this); // ?? sketchPhotoEntities = new ArrayList<PhotoEntity>(); // Button matchButton = (Button) rootView.findViewById(R.id.ct_licencePhotoMatch_button); matchButton.setOnClickListener(this); // vin??? InputFilter alphaNumericFilter = new InputFilter() { @Override public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) { for (int k = arg1; k < arg2; k++) { if (!Character.isLetterOrDigit(arg0.charAt(k))) { return ""; } } return null; } }; vin_edit = (EditText) rootView.findViewById(R.id.bi_vin_edit); vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps() }); brandEdit = (EditText) rootView.findViewById(R.id.bi_brand_edit); displacementEdit = (EditText) rootView.findViewById(R.id.csi_displacement_edit); transmissionEdit = (EditText) rootView.findViewById(R.id.csi_transmission_edit); runEdit = (EditText) rootView.findViewById(R.id.bi_mileage_edit); // // transmissionSpinner = (Spinner)rootView.findViewById(R.id.csi_transmission_spinner); // transmissionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { // @Override // public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { // transmissionEdit.setText(adapterView.getSelectedItem().toString()); // } // // @Override // public void onNothingSelected(AdapterView<?> adapterView) { // // } // }); // ?????? ScrollView view = (ScrollView) rootView.findViewById(R.id.root); view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); view.setFocusable(true); view.setFocusableInTouchMode(true); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.requestFocusFromTouch(); return false; } }); // ????????2? runEdit.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable edt) { String temp = edt.toString(); if (temp.contains(".")) { int posDot = temp.indexOf("."); if (posDot <= 0) return; if (temp.length() - posDot - 1 > 2) { edt.delete(posDot + 3, posDot + 4); } } else { if (temp.length() > 2) { edt.clear(); edt.append(temp.substring(0, 2)); } } } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); licencePhotoMatchEdit = (EditText) rootView.findViewById(R.id.ct_licencePhotoMatch_edit); licencePhotoMatchEdit.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { licencePhotoMatchEdit.setError(null); } @Override public void afterTextChanged(Editable editable) { licencePhotoMatchEdit.setError(null); } }); // ?? carNumberEdit = (EditText) rootView.findViewById(R.id.ci_plateNumber_edit); carNumberEdit.setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) }); // ? portedProcedureRow = (TableRow) rootView.findViewById(R.id.ct_ported_procedure); // ?Spinner setRegLocationSpinner(); setCarColorSpinner(); setFirstLogTimeSpinner(); setManufactureTimeSpinner(); setTransferCountSpinner(); setLastTransferTimeSpinner(); setYearlyCheckAvailableDateSpinner(); setAvailableDateYearSpinner(); setBusinessInsuranceAvailableDateYearSpinner(); setOtherSpinners(); // </editor-fold> mCarSettings = new CarSettings(); // ??xml if (vehicleModel == null) { mProgressDialog = ProgressDialog.show(rootView.getContext(), null, "?..", false, false); Thread thread = new Thread(new Runnable() { @Override public void run() { try { ParseXml(); // jsonData?? if (!jsonData.equals("")) { modifyMode = true; letsEnterModifyMode(); } } catch (Exception e) { e.printStackTrace(); } } }); thread.start(); } return rootView; }