public StringWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); mAnswer = new EditText(context); mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); TableLayout.LayoutParams params = new TableLayout.LayoutParams(); params.setMargins(7, 5, 7, 5); mAnswer.setLayoutParams(params); // capitalize the first letter of the sentence mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false)); // needed to make long read only text scroll mAnswer.setHorizontallyScrolling(false); mAnswer.setSingleLine(false); if (prompt != null) { mReadOnly = prompt.isReadOnly(); String s = prompt.getAnswerText(); if (s != null) { mAnswer.setText(s); } if (mReadOnly) { mAnswer.setBackgroundDrawable(null); mAnswer.setFocusable(false); mAnswer.setClickable(false); } } addView(mAnswer); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); overridePendingTransition(R.anim.pull_in_from_left, R.anim.pull_out_to_left); setContentView(R.layout.pass); close = (Button) findViewById(R.id.pass_cl); login = (Button) findViewById(R.id.pass_yes); forget = (Button) findViewById(R.id.pass_no); uName = (EditText) findViewById(R.id.pass_username); pass = (EditText) findViewById(R.id.pass_pwd); tView = (TextView) findViewById(R.id.pass_title); close.setOnClickListener(this); login.setOnClickListener(this); forget.setOnClickListener(this); db.open(); Cursor mCursor = db.getAllRecords(); mCursor.moveToFirst(); rName = mCursor.getString(1); if (mCursor.getCount() > 0) { uName.setClickable(false); uName.setBackgroundResource(R.drawable.keypad1); } db.close(); tView.setText(rName + " @ MoneyMan"); uName.setText(rName); } // end onCreate()
private void setEditable(boolean editable) { mEditView.setEnabled(editable); mEditView.setFocusableInTouchMode(editable); mEditView.setFocusable(editable); mEditView.setClickable(editable); mEditView.setLongClickable(editable); }
@Override protected void onResume() { super.onResume(); etLectNum = (EditText) findViewById(R.id.etLectNum); etLectTitle = (EditText) findViewById(R.id.etLectTitle); etLectDescription = (EditText) findViewById(R.id.etLectDescription); tvLastLect = (TextView) findViewById(R.id.tvLastLect); bSubmit = (Button) findViewById(R.id.bLectSubmit); spf = PreferenceManager.getDefaultSharedPreferences(this); ed = spf.edit(); semSelected = spf.getInt("SemesterSelected", 0); courseSelected = spf.getString("CourseSelected", null); dbh = new DBHelper(this); if (getIntent().getExtras().getBoolean("Update")) { Cursor rs = dbh.getLectureData(semSelected, courseSelected, spf.getInt("LectureSelected", 0)); rs.moveToFirst(); etLectNum.setText(String.valueOf(rs.getInt(rs.getColumnIndex(DBHelper.LECTURES_NUMBER)))); etLectNum.setFocusable(false); etLectNum.setClickable(false); etLectTitle.setText(rs.getString(rs.getColumnIndex(DBHelper.LECTURES_TITLE))); etLectDescription.setText(rs.getString(rs.getColumnIndex(DBHelper.LECTURES_DESCRIPTION))); rs.close(); dbh.close(); } else { tvLastLect.setText( "Last Lecture Number added: " + dbh.getLastAddedLecture(semSelected, courseSelected)); } bSubmit.setOnClickListener(this); }
// disable edittext fields editable after updating the profile public void setEditableOff(EditText et) { et.setLongClickable(false); et.setClickable(false); et.setCursorVisible(false); et.setTextColor(Color.parseColor("#000000")); et.setFocusable(false); et.setClickable(false); et.setEnabled(false); et.setFocusable(false); et.setFocusableInTouchMode(false); et.setBackgroundColor(Color.parseColor("#FEFEEB")); et.requestFocus(); findViewById(R.id.labelSection).setLayoutParams(new LinearLayout.LayoutParams(0, 0, 0f)); findViewById(R.id.editSection) .setLayoutParams( new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 0.7f)); }
@SuppressLint("SimpleDateFormat") public void onClick(View v) { // TODO Auto-generated method stub Date theDate = Calendar.getInstance().getTime(); SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd"); String date = dateFormat.format(theDate); // On list view if (restaurantId == null) { SimpleDateFormat created = new SimpleDateFormat("dd MMM yyyy hh:mm aa"); String createdDate = created.format(theDate); helper.insert( textTitle.getText().toString(), textContent.getText().toString(), date, "Created on " + createdDate.toString()); count++; finish(); } else { if (save.getText().toString() == "edit") { save.setText("save"); textContent.setClickable(true); textContent.setFocusableInTouchMode(true); textTitle.setFocusable(true); textTitle.setClickable(true); textTitle.setFocusableInTouchMode(true); } SimpleDateFormat modified = new SimpleDateFormat("dd MMM yyyy hh:mm aa"); String modifiedDate = modified.format(theDate); helper.update( restaurantId, textTitle.getText().toString(), textContent.getText().toString(), date, "Modified on " + modifiedDate.toString()); Toast.makeText(getApplicationContext(), "saved", Toast.LENGTH_SHORT).show(); } }
private void load() { // TODO Auto-generated method stub save.setText("edit"); textContent.setFocusable(false); textContent.setClickable(false); textContent.setFocusableInTouchMode(false); textTitle.setFocusable(false); textTitle.setClickable(false); textTitle.setFocusableInTouchMode(false); Cursor c = helper.getById(restaurantId); c.moveToFirst(); textTitle.setText(helper.getTitle(c)); textContent.setText(helper.getContent(c)); dayEntries.setText(helper.getCreatedDate(c)); c.close(); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.rlayout); Aco = (EditText) findViewById(R.id.Aco); Bco = (EditText) findViewById(R.id.Bco); Cco = (EditText) findViewById(R.id.Cco); secret = (EditText) findViewById(R.id.supsec); // settings PreferenceManager.setDefaultValues(this, R.xml.preferences, true); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); i = prefs.getBoolean("PREF_SHOW_I", true); sec = prefs.getBoolean("PREF_SEC", false); // secret stuff if (!sec || i) { secret.setFocusable(false); secret.setClickable(false); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_registration); // session user = SessionManager.getInstance(getApplicationContext()).retrieveSession("person", Person.class); // binding firstName = (EditText) findViewById(R.id.firstNameInput); username = (EditText) findViewById(R.id.usernameInput); username.setClickable(false); lastName = (EditText) findViewById(R.id.lastNameInput); password = (EditText) findViewById(R.id.passwordInput); confirmPassword = (EditText) findViewById(R.id.confirmPasswordInput); change = (Button) findViewById(R.id.submitButton); // input fill firstName.setText(user.getName()); lastName.setText(user.getSurname()); username.setText(user.getCredentials().getUsername()); password.setText(user.getCredentials().getPassword()); change.setOnClickListener(onChange); // input validation inputs = Arrays.asList( new Input(firstName, Input.TEXT_MAIN_PATTERN, getString(R.string.firstname_error)), new Input(lastName, Input.TEXT_MAIN_PATTERN, getString(R.string.lastname_error)), new Input(password, Input.PASSWORD_PATTERN, getString(R.string.password_error)), new Input( confirmPassword, Input.PASSWORD_PATTERN, getString(R.string.matching_password_error))); // hide keyboard getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); }
public LunarDatePicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // initialization based on locale setCurrentLocale(Locale.getDefault()); // /@M:{comment these lines // TypedArray attributesArray = context.obtainStyledAttributes(attrs, // R.styleable.LunarDatePicker, // defStyle, 0); // boolean spinnersShown = // attributesArray.getBoolean(R.styleable.LunarDatePicker_spinnersShown, // DEFAULT_SPINNERS_SHOWN); // boolean calendarViewShown = attributesArray.getBoolean( // R.styleable.LunarDatePicker_calendarViewShown, // DEFAULT_CALENDAR_VIEW_SHOWN); // int startYear = // attributesArray.getInt(R.styleable.LunarDatePicker_startYear, // DEFAULT_START_YEAR); // int endYear = attributesArray.getInt(R.styleable.LunarDatePicker_endYear, // DEFAULT_END_YEAR); // String minDate = // attributesArray.getString(R.styleable.LunarDatePicker_minDate); // String maxDate = // attributesArray.getString(R.styleable.LunarDatePicker_maxDate); // int layoutResourceId =R.layout.date_picker; // attributesArray.getResourceId(R.styleable.LunarDatePicker_layout, // R.layout.date_picker); // attributesArray.recycle(); // /} // /M:add @{ boolean spinnersShown = DEFAULT_SPINNERS_SHOWN; boolean calendarViewShown = DEFAULT_CALENDAR_VIEW_SHOWN; int startYear = DEFAULT_START_YEAR; int endYear = DEFAULT_END_YEAR; int layoutResourceId = R.layout.date_picker; // /} LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(layoutResourceId, this, true); OnValueChangeListener onChangeListener = new OnValueChangeListener() { public void onValueChange(NumberPicker picker, int oldVal, int newVal) { updateInputState(); mTempDate.setTimeInMillis(mCurrentDate.getTimeInMillis()); int gregorianYear = mTempDate.get(Calendar.YEAR); int gregorianMonth = mTempDate.get(Calendar.MONTH) + 1; int gregorianDay = mTempDate.get(Calendar.DAY_OF_MONTH); int lunarDates[] = LunarUtil.calculateLunarByGregorian(gregorianYear, gregorianMonth, gregorianDay); // take care of wrapping of days and months to update greater // fields if (picker == mDaySpinner) { if (oldVal > 27 && newVal == 1) { mTempDate.add(Calendar.DAY_OF_MONTH, 1); } else if (oldVal == 1 && newVal > 27) { mTempDate.add(Calendar.DAY_OF_MONTH, -1); } else { mTempDate.add(Calendar.DAY_OF_MONTH, newVal - oldVal); } } else if (picker == mMonthSpinner) { int leapMonth = 0; int monthCountDays = 0; if (oldVal > 10 && newVal == 0) { leapMonth = LunarUtil.leapMonth(lunarDates[0]); if (leapMonth == 12) { monthCountDays = LunarUtil.daysOfLeapMonthInLunarYear(lunarDates[0]); } else { monthCountDays = LunarUtil.daysOfALunarMonth(lunarDates[0], 12); } mTempDate.add(Calendar.DAY_OF_MONTH, monthCountDays); } else if (oldVal == 0 && newVal > 10) { leapMonth = LunarUtil.leapMonth(lunarDates[0] - 1); if (leapMonth == 12) { monthCountDays = LunarUtil.daysOfLeapMonthInLunarYear(lunarDates[0]); } else { monthCountDays = LunarUtil.daysOfALunarMonth(lunarDates[0] - 1, 12); } mTempDate.add(Calendar.DAY_OF_MONTH, -monthCountDays); } else { leapMonth = LunarUtil.leapMonth(lunarDates[0]); // move to previous if ((newVal - oldVal) < 0) { if (leapMonth == 0) { monthCountDays = LunarUtil.daysOfALunarMonth(lunarDates[0], newVal + 1); } else { // leap year if (newVal < leapMonth) { monthCountDays = LunarUtil.daysOfALunarMonth(lunarDates[0], newVal + 1); } else if (newVal == leapMonth) { monthCountDays = LunarUtil.daysOfLeapMonthInLunarYear(lunarDates[0]); } else { monthCountDays = LunarUtil.daysOfALunarMonth(lunarDates[0], newVal); } } monthCountDays = -monthCountDays; } else { // move to next month if (leapMonth == 0) { monthCountDays = LunarUtil.daysOfALunarMonth(lunarDates[0], oldVal + 1); } else { // leap year if (oldVal < leapMonth) { monthCountDays = LunarUtil.daysOfALunarMonth(lunarDates[0], oldVal + 1); } else if (oldVal == leapMonth) { monthCountDays = LunarUtil.daysOfLeapMonthInLunarYear(lunarDates[0]); } else { monthCountDays = LunarUtil.daysOfALunarMonth(lunarDates[0], oldVal); } } } mTempDate.add(Calendar.DAY_OF_MONTH, monthCountDays); } } else if (picker == mYearSpinner) { int orientation = newVal - oldVal > 0 ? LunarUtil.INCREASE_A_LUANR_YEAR : LunarUtil.DECREATE_A_LUANR_YEAR; mTempDate = LunarUtil.decreaseOrIncreaseALunarYear( mTempDate, lunarDates[1], lunarDates[2], orientation); } else { throw new IllegalArgumentException(); } // now set the date to the adjusted one setDate( mTempDate.get(Calendar.YEAR), mTempDate.get(Calendar.MONTH), mTempDate.get(Calendar.DAY_OF_MONTH)); updateSpinners(); updateCalendarView(); notifyDateChanged(); } }; mSpinners = (LinearLayout) findViewById(R.id.pickers); // calendar view day-picker mCalendarView = (CalendarView) findViewById(R.id.calendar_view); mCalendarView.setOnDateChangeListener( new CalendarView.OnDateChangeListener() { public void onSelectedDayChange(CalendarView view, int year, int month, int monthDay) { setDate(year, month, monthDay); updateSpinners(); notifyDateChanged(); } }); // day mDaySpinner = (NumberPicker) findViewById(R.id.day); // /M: comment this line @{ // mDaySpinner.setFormatter(NumberPicker.TWO_DIGIT_FORMATTER); // /} mDaySpinner.setOnLongPressUpdateInterval(100); mDaySpinner.setOnValueChangedListener(onChangeListener); // mDaySpinner has 3 child,topButton,editText,bottomButtom if (mDaySpinner.getChildCount() == PICKER_CHILD_COUNT) { // set the Middle EditText of Numberpicker read only. mDaySpinnerInput = (EditText) mDaySpinner.getChildAt(1); mDaySpinnerInput.setClickable(false); mDaySpinnerInput.setFocusable(false); } else { // Normally,this will always not happen. mDaySpinnerInput = new EditText(context); Log.e(TAG, "mDaySpinner.getChildCount() != 3,It isn't init ok."); } // month mMonthSpinner = (NumberPicker) findViewById(R.id.month); mMonthSpinner.setMinValue(0); mMonthSpinner.setMaxValue(mNumberOfMonths - 1); mMonthSpinner.setDisplayedValues(mShortMonths); mMonthSpinner.setOnLongPressUpdateInterval(200); mMonthSpinner.setOnValueChangedListener(onChangeListener); // mDaySpinner has 3 child,topButton,editText,bottomButtom if (mMonthSpinner.getChildCount() == PICKER_CHILD_COUNT) { // set the Middle EditText of Numberpicker read only. mMonthSpinnerInput = (EditText) mMonthSpinner.getChildAt(1); mMonthSpinnerInput.setClickable(false); mMonthSpinnerInput.setFocusable(false); } else { // Normally,this will always not happen. mMonthSpinnerInput = new EditText(context); Log.e(TAG, "mMonthSpinner.getChildCount() != 3,It isn't init ok."); } // year mYearSpinner = (NumberPicker) findViewById(R.id.year); mYearSpinner.setOnLongPressUpdateInterval(100); mYearSpinner.setOnValueChangedListener(onChangeListener); // mDaySpinner has 3 child,topButton,editText,bottomButtom if (mYearSpinner.getChildCount() == PICKER_CHILD_COUNT) { // set the Middle EditText of Numberpicker read only. mYearSpinnerInput = (EditText) mYearSpinner.getChildAt(1); mYearSpinnerInput.setClickable(false); mYearSpinnerInput.setFocusable(false); } else { // Normally,this will always not happen. mYearSpinnerInput = new EditText(context); Log.e(TAG, "mYearSpinner.getChildCount() != 3,It isn't init ok."); } // show only what the user required but make sure we // show something and the spinners have higher priority if (!spinnersShown && !calendarViewShown) { setSpinnersShown(true); } else { setSpinnersShown(spinnersShown); setCalendarViewShown(calendarViewShown); } // set the min date giving priority of the minDate over startYear mTempDate.clear(); mTempDate.set(startYear, 0, 1); setMinDate(mTempDate.getTimeInMillis()); // set the max date giving priority of the maxDate over endYear mTempDate.clear(); mTempDate.set(endYear, 11, 31); setMaxDate(mTempDate.getTimeInMillis()); // initialize to current date mCurrentDate.setTimeInMillis(System.currentTimeMillis()); init( mCurrentDate.get(Calendar.YEAR), mCurrentDate.get(Calendar.MONTH), mCurrentDate.get(Calendar.DAY_OF_MONTH), null); // re-order the number spinners to match the current date format reorderSpinners(); // set content descriptions AccessibilityManager accessibilityManager = (AccessibilityManager) context.getSystemService(context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isEnabled()) { setContentDescriptions(); } }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.version); EditText mEditor = (EditText) findViewById(R.id.editor); mEditor.setClickable(false); mEditor.setFocusable(false); mEditor.setText( "" + "Photo Geolocator" + "\n" + getText(R.string.version) + " 1.6.2 (Build 201104061504)" + "\n" + "Free GNU license" + "\n" + "http://www.photogeolocator.org" + "\n" + "Mail: [email protected]" + "\n" + "\n" + getText(R.string.betaTestTeam) + "\n" + "Montxo - HTC Dream" + "\n" + "Marcello Anselmi Tamburini - LG Optimus One" + "\n" + "Pablo Carmona - HTC Magic" + "\n" + "Fritz Endres - HTC Desire" + "\n" + "Sebastián Ercoli - Samsung Galaxy S" + "\n" + "Maria del Mar Fontana - Motorola Dext" + "\n" + "Javier Gallego - HTC Hero" + "\n" + "Emiliano García - HTC Hero / Tatoo" + "\n" + "Manel García - HTC Tatoo" + "\n" + "Ken Gauger - VZW Samsung S Fascinate" + "\n" + "Javier Gavilán - HTC Hero" + "\n" + "David Godino - HTC Legend" + "\n" + "Enric Heredia - HTC Tatoo" + "\n" + "Masakazu Kawahara - IS05" + "\n" + "Jose Antonio López - HTC Dream" + "\n" + "Ángel Martínez - HTC Hero" + "\n" + "Juan Manuel Patón - HTC Hero" + "\n" + "Marco Antonio Pérez - HTC Magic / Nexus One" + "\n" + "Moisés Regalon - HTC Magic" + "\n" + "\n" + getText(R.string.thisAppUsesLibrary) + " Sanselan Android (http://code.google.com/p/sanselanandroid)"); }
public void setEditable(Boolean isEditable) { etTitle.setEnabled(isEditable); etTitle.setFocusable(isEditable); etTitle.setActivated(isEditable); etTitle.setClickable(!isEditable); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_profile); setupToolbar(); // Connect views editName = (EditText) findViewById(R.id.edit_name); editDateOfBirth = (EditText) findViewById(R.id.edit_date_of_birth); editPhone = (EditText) findViewById(R.id.edit_phone_number); editIDCardNumber = (EditText) findViewById(R.id.edit_id_card_number); editDescription = (EditText) findViewById(R.id.edit_description); editAvatar = (ImageView) findViewById(R.id.edit_avatar); editGender = (Spinner) findViewById(R.id.edit_gender); buttonChangeAvatar = (Button) findViewById(R.id.button_change_avatar); // Set up button change avatar buttonChangeAvatar.setOnClickListener(this); // set up date of birth input field editDateOfBirth.setFocusable(false); editDateOfBirth.setClickable(true); editDateOfBirth.setOnClickListener(this); // Determine whether the current user is an anonymous user if (!ParseAnonymousUtils.isLinked(ParseUser.getCurrentUser())) { // If current user is not anonymous user // Get current user data from Parse.com ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { // get user information editName.setText(currentUser.getString("name")); editDateOfBirth.setText(currentUser.getString("date_of_birth")); if (currentUser.getString("gender").equals("Male")) { editGender.setSelection(1); } else { editGender.setSelection(2); } editPhone.setText(currentUser.getString("phone")); editDescription.setText(currentUser.getString("description")); editIDCardNumber.setText(currentUser.getString("id_card_number")); // get avatar ParseFile file = currentUser.getParseFile("avatar"); file.getDataInBackground( new GetDataCallback() { @Override public void done(byte[] bytes, ParseException e) { Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); editAvatar.setImageBitmap(bitmap); } }); } } // Set up gender spinner List<String> list = new ArrayList<String>(); list.add("Male"); list.add("Female"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); editGender.setAdapter(dataAdapter); // Set up progress dialog progressDialog = new ProgressDialog(this); progressDialog.setMessage(this.getResources().getString(R.string.wait)); progressDialog.setCanceledOnTouchOutside(false); }