List of usage examples for android.widget TextView setEnabled
@android.view.RemotableViewMethod @Override public void setEnabled(boolean enabled)
From source file:co.nerdart.ourss.adapter.FeedsCursorAdapter.java
@Override protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) { ImageView indicatorImage = (ImageView) view.findViewById(R.id.indicator); if (cursor.getInt(isGroupPosition) == 1) { long feedId = cursor.getLong(idPosition); if (feedId == mSelectedFeedId) { view.setBackgroundResource(android.R.color.holo_blue_dark); } else {/*from w w w. j a v a2s.co m*/ view.setBackgroundResource(android.R.color.transparent); } indicatorImage.setVisibility(View.VISIBLE); TextView textView = ((TextView) view.findViewById(android.R.id.text1)); textView.setEnabled(true); textView.setText(cursor.getString(namePosition)); textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); int unreadCount; synchronized (mUnreadItemsByFeed) { unreadCount = mUnreadItemsByFeed.get(feedId); } textView.setText(cursor.getString(namePosition) + (unreadCount > 0 ? " (" + unreadCount + ")" : "")); view.findViewById(android.R.id.text2).setVisibility(View.GONE); View sortView = view.findViewById(R.id.sortitem); if (!sortViews.contains(sortView)) { // as we are reusing views, this is fine sortViews.add(sortView); } sortView.setVisibility(feedSort ? View.VISIBLE : View.GONE); final int groupPosition = cursor.getPosition(); if (!mGroupInitDone.get(groupPosition)) { mGroupInitDone.put(groupPosition, true); boolean savedExpandedState = cursor.getInt(isGroupCollapsedPosition) != 1; if (savedExpandedState && !isExpanded) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { mListView.expandGroup(groupPosition); } }); } if (savedExpandedState) indicatorImage.setImageResource(R.drawable.group_expanded); else indicatorImage.setImageResource(R.drawable.group_collapsed); } else { if (isExpanded) indicatorImage.setImageResource(R.drawable.group_expanded); else indicatorImage.setImageResource(R.drawable.group_collapsed); } } else { bindChildView(view, context, cursor); indicatorImage.setVisibility(View.GONE); } }
From source file:com.emman.tame.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.settings) { startActivity(new Intent(this, Settings.class)); return true; } else if (id == R.id.debug) { item.setChecked(!item.isChecked()); if (item.isChecked()) Utils.burntToast(this, getString(R.string.item_msg_tamelog, FILE_TAME_LOG)); updateSharedPrefs(mPreferences, TAME_DEBUG, Utils.boolToString(item.isChecked())); return true; } else if (id == R.id.sob) { item.setChecked(!item.isChecked()); TextView mSOBNote = (TextView) findViewById(R.id.sobnote); if (mSOBNote != null) mSOBNote.setEnabled(item.isChecked()); updateSharedPrefs(mPreferences, SET_ON_BOOT, Utils.boolToString(item.isChecked())); return true; }/* w w w . j a va 2 s . c om*/ return super.onOptionsItemSelected(item); }
From source file:com.nextgis.mobile.forms.DescriptionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.setRetainInstance(true); View view = inflater.inflate(R.layout.descriptfragment, container, false); final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item); final Map<String, ArrayList<String>> mlCategories = new HashMap<String, ArrayList<String>>(); //fill spinners from xml data XmlPullParser parser = Xml.newPullParser(); try {//from ww w. j a v a 2 s . co m File file = new File(getActivity().getExternalFilesDir(null), "categories.xml"); if (file != null) { if (!file.exists()) { createExternalStoragePrivateFile(); file = new File(getActivity().getExternalFilesDir(null), "categories.xml"); } InputStream in = new BufferedInputStream(new FileInputStream(file)); InputStreamReader isr = new InputStreamReader(in); // auto-detect the encoding from the stream parser.setInput(isr); int eventType = parser.getEventType(); String sCatVal = null; while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_DOCUMENT: break; case XmlPullParser.START_TAG: String name = parser.getName(); if (name.equalsIgnoreCase("category")) { sCatVal = parser.getAttributeValue(null, "name"); adapter.add(sCatVal); mlCategories.put(sCatVal, new ArrayList<String>()); } else if (name.equalsIgnoreCase("subcategory")) { if (sCatVal != null) { String sSubCatVal = parser.getAttributeValue(null, "name"); mlCategories.get(sCatVal).add(sSubCatVal); } } break; } eventType = parser.next(); } if (in != null) { in.close(); } } } catch (IOException e) { // TODO } catch (Exception e) { // TODO } Spinner spinner = (Spinner) view.findViewById(R.id.spinner_cat); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { final Spinner subspinner = (Spinner) getView().findViewById(R.id.spinner_subcat); //subspinner String sCat = adapter.getItem(arg2).toString(); TextView textview = (TextView) getView().findViewById(R.id.spinner_subcat_custom); if (sCat.equalsIgnoreCase("custom")) { //enable text item textview.setEnabled(true); } else { textview.setEnabled(false); } ArrayAdapter<String> subadapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, mlCategories.get(sCat)); subadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); subspinner.setAdapter(subadapter); } public void onNothingSelected(AdapterView<?> arg0) { } }); onStoreValues(); return view; }
From source file:org.travey.travey.SettingsFragment.java
public void processFinish(String output) { //assuming success for the moment Log.i("**************", "output=" + output); if (output.indexOf("yes") > -1) { mRegistered = true;/* w ww .j av a 2 s. c o m*/ myPrefs = this.getActivity().getSharedPreferences("myPrefs", this.getActivity().MODE_PRIVATE); SharedPreferences.Editor editor = myPrefs.edit(); editor.putString("participantID", participantID); editor.commit(); save(mActiveCheckboxChecked, mRequestingLocationUpdates, mRegistered); CheckBox checkBox = (CheckBox) rootView.findViewById(R.id.checkBox); EditText editText = (EditText) rootView.findViewById(R.id.editText); Button button = (Button) rootView.findViewById(R.id.button); TextView textView4 = (TextView) rootView.findViewById(R.id.textView4); TextView textView5 = (TextView) rootView.findViewById(R.id.textView5); textView4.setText(R.string.step1); textView4.setEnabled(false); textView5.setEnabled(true); checkBox.setEnabled(true); editText.setEnabled(false); button.setText(R.string.reset_button); EventBus bus = EventBus.getDefault(); bus.post(new RegistrationStatusChanged("1")); } else { TextView textView4 = (TextView) rootView.findViewById(R.id.textView4); textView4.setText(R.string.participant_not_found); } dialog.dismiss(); }
From source file:org.voidsink.anewjkuapp.activity.KusssAuthenticatorActivity.java
@Override public void onCreate(Bundle savedInstanceState) { UIUtils.applyTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); setSupportActionBar(toolbar);/*from w w w . j av a 2 s . c om*/ initActionBar(); mAccountManager = AccountManager.get(this); Intent mIntent = getIntent(); String accountName = null; Boolean mIsNewAccount = false; Account mAccount = AppUtils.getAccount(this); if (mAccount != null) { accountName = mAccount.name; if (mIntent != null) { mIntent.removeExtra(KusssAuthenticator.ARG_IS_ADDING_NEW_ACCOUNT); mIntent.putExtra(KusssAuthenticator.ARG_ACCOUNT_NAME, mAccount.name); mIntent.putExtra(KusssAuthenticator.ARG_ACCOUNT_TYPE, mAccount.type); } } else if (mIntent != null) { accountName = getIntent().getStringExtra(KusssAuthenticator.ARG_ACCOUNT_NAME); mIsNewAccount = mIntent.getBooleanExtra(KusssAuthenticator.ARG_IS_ADDING_NEW_ACCOUNT, false); if (!mIntent.hasExtra(KusssAuthenticator.ARG_ACCOUNT_TYPE)) { mIntent.putExtra(KusssAuthenticator.ARG_ACCOUNT_TYPE, KusssAuthenticator.ACCOUNT_TYPE); } } if (mAuthTokenType == null) { mAuthTokenType = KusssAuthenticator.AUTHTOKEN_TYPE_READ_ONLY; } if (!mIsNewAccount) { if (accountName != null) { final TextView tvAccountName = (TextView) findViewById(R.id.accountName); if (tvAccountName != null) { tvAccountName.setText(accountName); tvAccountName.setEnabled(false); } } } mSubmit = (Button) findViewById(R.id.accountLogin); mSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ((android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) && (ContextCompat.checkSelfPermission(KusssAuthenticatorActivity.this, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED)) { new AlertDialog.Builder(KusssAuthenticatorActivity.this) .setMessage(R.string.alert_permission_get_accounts) .setPositiveButton(R.string.button_ok, null).setCancelable(false).show(); } else { submit(); } } }); }
From source file:sysnetlab.android.sdc.ui.fragments.ExperimentSensorSetupFragment.java
private void updateAndroidSensorSetupView(AbstractSensor sensor) { TextView tv = (TextView) mView.findViewById(R.id.textview_sensor_setup_sensor_name); tv.setText(sensor.getName());/* w w w. j av a2s. co m*/ Log.d("SensorDataCollector", "Android sensor."); UserInterfaceUtils.fillSensorProperties(getActivity(), (ListView) mView.findViewById(R.id.listview_sensor_setup_sensor_properties), sensor); EditText etSamplingRate = (EditText) mView.findViewById(R.id.edittext_sensor_steup_sampling_rate); Button btnSetSamplingRate = (Button) mView.findViewById(R.id.button_sensor_setup_set_parameter); btnSetSamplingRate.setVisibility(View.VISIBLE); TextView tvSamplingRate = (TextView) mView.findViewById(R.id.textview_sensor_setup_sampling_rate); if (((AndroidSensor) sensor).isStreamingSensor()) { etSamplingRate.setText(String.valueOf(1000000. / ((AndroidSensor) sensor).getSamplingInterval())); etSamplingRate.setEnabled(true); tvSamplingRate.setEnabled(true); etSamplingRate.setVisibility(View.VISIBLE); tvSamplingRate.setVisibility(View.VISIBLE); btnSetSamplingRate.setVisibility(View.VISIBLE); Log.d("SensorDataCollector", "Streaming sensor."); } else { etSamplingRate.setText(getActivity().getResources().getString(R.string.text_not_applicable)); etSamplingRate.setEnabled(false); tvSamplingRate.setEnabled(false); etSamplingRate.setVisibility(View.GONE); tvSamplingRate.setVisibility(View.GONE); btnSetSamplingRate.setVisibility(View.GONE); Log.d("SensorDataCollector", "Non-streaming (onchange) sensor."); } }
From source file:com.makotogo.mobile.hoursdroid.HoursDetailFragment.java
private void configureBreakTime(View view) { TextView breakTimeTextView = (TextView) view.findViewById(R.id.textview_hours_detail_break); breakTimeTextView.setEnabled(isThisHoursRecordNotActive()); if (isThisHoursRecordActive()) { breakTimeTextView/* www . ja v a 2 s . c o m*/ .setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.no_border, null)); } else { breakTimeTextView .setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.rounded_border, null)); } breakTimeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fragmentManager = getFragmentManager(); Integer minutes = renderStorageBreakForEdit(mHours.getBreak().intValue()); Log.d(TAG, "Number of minutes: " + minutes); // Max minutes can at most be number of minutes diff between end and begin Integer maxMinutes = (int) (mHours.getEnd().getTime() - mHours.getBegin().getTime()) / 60000; NumberPickerFragment numberPickerFragment = FragmentFactory.createNumberPickerFragment(minutes, maxMinutes, "Break Time"); numberPickerFragment.setTargetFragment(HoursDetailFragment.this, REQUEST_BREAK); numberPickerFragment.show(fragmentManager, NumberPickerFragment.DIALOG_TAG); } }); breakTimeTextView.setText(renderTimePeriodForDisplay(mHours.getBreak())); }
From source file:com.makotogo.mobile.hoursdroid.HoursDetailFragment.java
private void configureEndDate(View view) { TextView endDateTextView = (TextView) view.findViewById(R.id.textview_hours_detail_end_date); endDateTextView.setEnabled(isThisHoursRecordNotActive()); if (isThisHoursRecordActive()) { endDateTextView.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.no_border, null)); } else {/* w w w .j a v a 2 s . c o m*/ endDateTextView .setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.rounded_border, null)); } endDateTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fragmentManager = getFragmentManager(); // If there is already a Date displayed, use that. Date dateToUse = (mHours.getEnd() == null) ? new Date() : mHours.getEnd(); DateTimePickerFragment datePickerFragment = FragmentFactory.createDatePickerFragment(dateToUse, "End", DateTimePickerFragment.BOTH); datePickerFragment.setTargetFragment(HoursDetailFragment.this, REQUEST_END_DATE_PICKER); datePickerFragment.show(fragmentManager, DateTimePickerFragment.DIALOG_TAG); } }); if (mHours.getEnd() != null) { LocalDateTime endDateTime = new LocalDateTime(mHours.getEnd().getTime()); endDateTextView.setText(endDateTime.toString(DATE_FORMAT_PATTERN)); } }
From source file:com.makotogo.mobile.hoursdroid.HoursDetailFragment.java
private void configureBeginDate(View view) { TextView beginDateTextView = (TextView) view.findViewById(R.id.textview_hours_detail_begin_date); beginDateTextView.setEnabled(isThisHoursRecordNotActive()); if (isThisHoursRecordActive()) { beginDateTextView/*from w w w . ja v a 2 s .c om*/ .setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.no_border, null)); } else { beginDateTextView .setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.rounded_border, null)); } beginDateTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fragmentManager = getFragmentManager(); // If there is already a Date displayed, use that. Date dateToUse = (mHours.getBegin() == null) ? new Date() : mHours.getBegin(); DateTimePickerFragment datePickerFragment = FragmentFactory.createDatePickerFragment(dateToUse, "Begin", DateTimePickerFragment.BOTH); datePickerFragment.setTargetFragment(HoursDetailFragment.this, REQUEST_BEGIN_DATE_PICKER); datePickerFragment.show(fragmentManager, DateTimePickerFragment.DIALOG_TAG); } }); if (mHours.getBegin() != null) { LocalDateTime beginDateTime = new LocalDateTime(mHours.getBegin().getTime()); beginDateTextView.setText(beginDateTime.toString(DATE_FORMAT_PATTERN)); } }
From source file:com.morgan.sunrisealarm.MainActivity.java
private void setupClient() { Log.d(TAG, "setupClient()"); mOnOffSwitchChanged = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { WidgetId widget = new WidgetId(buttonView); Log.d(TAG, "OnCheckedChangeListener"); TextView dayText = (TextView) findViewById(widget.getDayTextId()); TextView alarmTimeText = (TextView) findViewById(widget.getAlarmTextId()); if (isChecked) { dayText.setEnabled(true); alarmTimeText.setEnabled(true); alarmTimeText.setTextColor(getResources().getColor(android.R.color.black)); AlarmTime time = new AlarmTime(alarmTimeText.getText().toString()); Command command = new Command(); command.setAlarm(widget.getAlarmId(), time.getHour(), time.getHour()); } else { dayText.setEnabled(false); alarmTimeText.setEnabled(false); alarmTimeText.setTextColor(dayText.getTextColors()); AlarmTime time = new AlarmTime(0, 0); alarmTimeText.setText(time.getString()); Command command = new Command(); command.setAlarm(widget.getAlarmId(), Constants.HOUR_ALARM_OFF, Constants.MIN_ALARM_OFF); }// w ww .ja v a2 s. c o m } }; mBluetoothClient = new BluetoothClient(getApplicationContext(), mHandler); BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(mAddress); mBluetoothClient.connect(device); }