List of usage examples for android.view View setEnabled
@RemotableViewMethod public void setEnabled(boolean enabled)
From source file:Main.java
/** * Enables/Disables input view according to the state of the survey. * Sent surveys cannot be modified./*from w ww . ja va 2s . co m*/ * * @param view */ public static void updateReadOnly(View view, boolean readOnly) { if (view == null) { return; } if (view instanceof RadioGroup) { RadioGroup radioGroup = (RadioGroup) view; for (int i = 0; i < radioGroup.getChildCount(); i++) { radioGroup.getChildAt(i).setEnabled(!readOnly); } } else { view.setEnabled(!readOnly); } }
From source file:Main.java
/** * Disable all the childs of the selected root view * * @param rootView View to iterate in order to disable all its childs * @param alpha Alpha to set to disabled elements *//*from w w w . j a v a 2 s .co m*/ public static void disableView(ViewGroup rootView, float alpha) { int count = rootView.getChildCount(); View v; //Go over the child list of the view and disable all for (int i = 0; i < count; i++) { v = rootView.getChildAt(i); if (v != null) { if (v instanceof ViewGroup) disableView((ViewGroup) v, alpha); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) v.setAlpha(alpha); v.setEnabled(false); } } }
From source file:com.oliversride.wordryo.Utils.java
public static void setEnabled(Dialog dialog, int id, boolean enabled) { View view = dialog.findViewById(id); view.setEnabled(enabled); }
From source file:com.silentcircle.common.util.ViewUtil.java
/** * Sets state (enabled/disabled) for viewGroup and its children. * * @param viewGroup ViewGroup for which to set state. * @param enabled State to set./*from w ww . j a v a 2 s . c o m*/ */ public static void setEnabled(final ViewGroup viewGroup, boolean enabled) { viewGroup.setEnabled(enabled); for (int i = 0; i < viewGroup.getChildCount(); i++) { View view = viewGroup.getChildAt(i); view.setEnabled(enabled); } }
From source file:com.sonymobile.androidapp.gridcomputing.utils.ViewUtils.java
/** * Updates the status bar with the current conditions. * * @param parent parent view.//from ww w .java2s. c o m * @param enabled the enabled condition. * @param paused the paused condition. * @param battery the battery condition. * @param charger the charger condition. * @param wifi the wifi condition. */ public static void updateStatusBar(final View parent, final boolean enabled, final boolean paused, final boolean battery, final boolean charger, final boolean wifi) { final boolean progress = battery && charger && wifi && !paused; final CheckableImageButton enableView = (CheckableImageButton) parent .findViewById(R.id.summary_menu_power_toggle); final View batteryView = parent.findViewById(R.id.iv_battery); final View chargerView = parent.findViewById(R.id.iv_charger); final View wifiView = parent.findViewById(R.id.iv_wifi); final StatusProgressBar progressView = (StatusProgressBar) parent.findViewById(R.id.progress); //final View standByProgressView = parent.findViewById(R.id.progress_stand_by); final TextView textView = (TextView) parent.findViewById(R.id.summary_status_text); boolean running = enabled && !paused; enableView.setChecked(running && progress); batteryView.setEnabled(running); chargerView.setEnabled(running); wifiView.setEnabled(running); textView.setEnabled(running); batteryView.setActivated(running && battery); chargerView.setActivated(running && charger); wifiView.setActivated(running && wifi); textView.setActivated(running && progress); if (running) { enableView.setImageResource(R.drawable.power_bt); if (progress) { textView.setText(R.string.helping_out); progressView.changeMode(StatusProgressBar.ProgressStatus.RUNNING); } else { textView.setText(R.string.stand_by); progressView.changeMode(StatusProgressBar.ProgressStatus.STAND_BY); } } else { progressView.changeMode(StatusProgressBar.ProgressStatus.NONE); if (!enabled) { enableView.setImageResource(R.drawable.power_bt_disabled); textView.setText(R.string.disabled); } else { enableView.setImageResource(R.drawable.power_bt_paused); textView.setText(R.string.paused); } } }
From source file:com.samsung.msca.samsungvr.sampleapp.Util.java
public static void setEnabled(List<View> viewGroupStack, View v, boolean enabled) { if (null == viewGroupStack) { viewGroupStack = new ArrayList<>(); }//from w ww. j ava 2 s. c om viewGroupStack.clear(); viewGroupStack.add(v); while (viewGroupStack.size() > 0) { View current = viewGroupStack.remove(0); current.setEnabled(enabled); if (current instanceof ViewGroup) { ViewGroup vg = (ViewGroup) current; for (int i = vg.getChildCount() - 1; i >= 0; i -= 1) { viewGroupStack.add(vg.getChildAt(i)); } } } }
From source file:org.zakky.memopad.MyDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setContentView(R.layout.dialog); dialog.setTitle(R.string.app_name);// w ww. j a v a 2 s . c o m dialog.findViewById(R.id.ok_button).setOnClickListener(new OnClickListener() { public void onClick(View v) { v.setEnabled(false); final CheckBox box = (CheckBox) dialog.findViewById(R.id.show_this_dialog_at_startup); final SharedPreferences pref = dialog.getContext().getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE); final Editor editor = pref.edit(); try { editor.putBoolean(PREF_KEY_SHOW_AT_STARTUP, box.isChecked()); } finally { editor.commit(); } dialog.dismiss(); } }); return dialog; }
From source file:com.google.reviewit.AbandonFragment.java
private void init(final Change change) { ((ExpandableCommitMessageView) v(R.id.commitMessage)).init(change); v(R.id.abandonButton).setOnClickListener(new View.OnClickListener() { @Override//from www . jav a 2 s. co m public void onClick(final View v) { v.setEnabled(false); v.setBackgroundColor(widgetUtil.color(R.color.buttonDisabled)); new AsyncTask<Change, Void, String>() { @Override protected String doInBackground(Change... changes) { Change change = changes[0]; try { change.abandon(textOf(R.id.abandonMessageInput).trim()); return null; } catch (RestApiException e) { if (e instanceof HttpStatusException) { HttpStatusException se = (HttpStatusException) e; return getString(R.string.abandon_error, se.getStatusCode(), se.getStatusText()); } else { return e.getMessage(); } } } protected void onPostExecute(String errorMsg) { if (errorMsg != null) { v.setEnabled(true); v.setBackgroundColor(widgetUtil.color(R.color.button)); widgetUtil.showError(errorMsg); } else { widgetUtil.toast(R.string.change_abandoned); display(SortChangesFragment.class); } } }.execute(change); } }); }
From source file:com.google.reviewit.RestoreFragment.java
private void init(final Change change) { ((ExpandableCommitMessageView) v(R.id.commitMessage)).init(change); v(R.id.restoreButton).setOnClickListener(new View.OnClickListener() { @Override// ww w. j a va 2s .c o m public void onClick(final View v) { v.setEnabled(false); v.setBackgroundColor(widgetUtil.color(R.color.buttonDisabled)); new AsyncTask<Change, Void, String>() { @Override protected String doInBackground(Change... changes) { Change change = changes[0]; try { change.restore(textOf(R.id.restoreMessageInput).trim()); return null; } catch (RestApiException e) { if (e instanceof HttpStatusException) { HttpStatusException se = (HttpStatusException) e; return getString(R.string.restore_error, se.getStatusCode(), se.getStatusText()); } else { return e.getMessage(); } } } protected void onPostExecute(String errorMsg) { if (errorMsg != null) { v.setEnabled(true); v.setBackgroundColor(widgetUtil.color(R.color.button)); widgetUtil.showError(errorMsg); } else { widgetUtil.toast(R.string.change_restored); display(SortChangesFragment.class); } } }.execute(change); } }); }
From source file:com.jtechme.apphub.views.AppListAdapter.java
private void setupView(View view, Cursor cursor, ViewHolder holder) { final App app = new App(cursor); holder.name.setText(app.name);//from w ww .ja v a2 s. co m holder.summary.setText(app.summary); ImageLoader.getInstance().displayImage(app.iconUrl, holder.icon, displayImageOptions); holder.status.setText(getVersionInfo(app)); holder.license.setText(app.license); // Disable it all if it isn't compatible... final View[] views = { view, holder.status, holder.summary, holder.license, holder.name, }; for (View v : views) { v.setEnabled(app.compatible && !app.isFiltered()); } }