void clear() { setText(""); setImage(null); setFont(parent.getFont()); setForeground(parent.getForeground()); setBackground(parent.getBackground()); }
private void handleDispose(Event event) { if (parent != null) { parent.removeItem(RadioItem.this); } if (button != null) { button.dispose(); if (parent != null && !parent.isDisposed()) parent.layout(false); } RadioItem.this.parent = null; button = null; }
private void initViews(View v) { hasRequestList = false; listView = (PullToRefreshListView) v.findViewById(R.id.listView); listView.setMode(Mode.BOTH); adapter = new MessageAdapter(mLeftList); // ListView actualListView = listView.getRefreshableView(); listView.setEmptyView(v.findViewById(android.R.id.empty)); listView.setAdapter(adapter); listView.setOnRefreshListener( new OnRefreshListener2<ListView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { curPage = 0; requestListData(curPage); } @Override public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { requestListData(curPage + 1); } }); listView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { DocMessageBean bean = (DocMessageBean) arg0.getAdapter().getItem(arg2); new ReadMessage().execute(bean.getID()); ((DocMessageBean) arg0.getAdapter().getItem(arg2)).setIsRead("1"); adapter.notifyDataSetChanged(); // 跳转逻辑 if (hasRequestList) { redirect(bean); } else { requestDocList(bean); } } }); mRadioGroup = (RadioGroup) v.findViewById(R.id.rg_message_center_title); mRadioGroup.setOnCheckedChangeListener(this); ((RadioButton) mRadioGroup.findViewById(R.id.rb_message_center_left)).setChecked(true); }
public RadioItem(final RadioGroup parent, int style, int index) { super(parent, checkStyle(style), checkIndex(parent, index)); this.parent = parent; this.button = parent.createButton(getStyle(), index); Listener listener = new Listener() { public void handleEvent(Event event) { if (event.type == SWT.Selection) handleSelection(event); else if (event.type == SWT.Dispose) handleDispose(event); } }; button.addListener(SWT.Selection, listener); addListener(SWT.Dispose, listener); parent.addItem(this, index); }
/** * @param isRead "0"已读,"1"未读 * @param pageNum 页码 */ private void requestListData(int pageNum) { int id = mRadioGroup.getCheckedRadioButtonId(); String isRead = ""; if (id == R.id.rb_message_center_left) { isRead = "1"; } else { isRead = "0"; } new GetAccountPushHistoryByIsReadTask().execute(isRead, pageNum + ""); }
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { View v = group.findViewById(checkedId); if (!(v instanceof RadioButton)) { return; } RadioButton b = (RadioButton) v; String message = (String) b.getTag(); app.settings().setDefaultMessage(message); }
private void addAccidentalListener() { final RadioGroup accidentalGroup = (RadioGroup) findViewById(R.id.accidentalSelection); accidentalGroup.setOnCheckedChangeListener( new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int checkedId) { flatDisplay.setVisibility(View.INVISIBLE); sharpDisplay.setVisibility(View.INVISIBLE); switch (checkedId) { case R.id.flatRadio: keyDisplay = KeyDisplay.DISPLAY_FLAT; break; case R.id.sharpRadio: keyDisplay = KeyDisplay.DISPLAY_SHARP; break; } } }); ((RadioButton) findViewById(R.id.sharpRadio)).setChecked(true); }
public void updateUI() { radioGroup.removeAllViews(); radioGroup.setOnCheckedChangeListener(null); String[] messageOptions = app.settings().getMessageOptionsArray(); RadioButton buttonToCheck = new RadioButton(getContext()); for (int i = 0; i < messageOptions.length; i++) { RadioButton button = new RadioButton(getContext()); button.setText(messageOptions[i]); button.setTag(messageOptions[i]); button.setId(i); if (app.settings().getDefaultMessage().equals(messageOptions[i])) { buttonToCheck = button; } radioGroup.addView(button); } buttonToCheck.setChecked(true); radioGroup.setOnCheckedChangeListener(this); removeOptionButton.setEnabled(messageOptions.length != 1); }
private void setupContent() { m_rollTypeRadioGroup = (RadioGroup) getRootView().findViewById(R.id.toggleGroupRollType); RollTypeClickListener rollTypeClickListener = new RollTypeClickListener(); for (int i = 0; i < m_rollTypeRadioGroup.getChildCount(); i++) { m_rollTypeRadioGroup.getChildAt(i).setOnClickListener(rollTypeClickListener); } m_dieTypeSpinner = (Spinner) getRootView().findViewById(R.id.spinnerDieType); setupSpinner(m_dieTypeSpinner, R.array.roller_die_types, 0); m_dieQuantityTv = (TextView) getRootView().findViewById(R.id.tvDieQuantity); m_dieQuantitySpinner = (Spinner) getRootView().findViewById(R.id.spinnerDieQuantity); setupSpinner(m_dieQuantitySpinner, R.array.roller_die_quantities, 0); m_rollButton = (Button) getRootView().findViewById(R.id.buttonRoll); m_rollButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { rollDice(); } }); m_resetButton = (Button) getRootView().findViewById(R.id.buttonReset); m_resetButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { resetRolls(); } }); m_rollResultTv = (TextView) getRootView().findViewById(R.id.textViewRollResult); m_rollSumTv = (TextView) getRootView().findViewById(R.id.textViewRollSum); m_rollResultList = (ListView) getRootView().findViewById(R.id.rollResultListView); resetRolls(); }
@Test public void testRadioGroup() { RadioGroup<String> group = new RadioGroup<>("rg", KEYS); assertSame(KEYS, group.getKeyList()); group.setValue("b"); group.getPrinter(out).print(null, "alpha"); out.assertOutNormed("<label><input type='radio' name='rg' value=''>alpha</label>"); group.getPrinter(out).print("b", null); out.assertOutNormed("<input type='radio' name='rg' value='b' checked>"); group.setValue(null); group.getPrinter(out).print(1); out.assertOutNormed("<label><input type='radio' name='rg' value='b'>beta</label>"); group.getPrinter(out).print("b"); out.assertOutNormed("<label><input type='radio' name='rg' value='b'>beta</label>"); group.print(out); out.assertOutNormed( "<label><input type='radio' name='rg' value='a'>alpha</label>\n<label><input type='radio' name='rg' value='b'>beta</label>\n"); group.setHorizontal(false).print(out); out.assertOutNormed( "<label><input type='radio' name='rg' value='a'>alpha</label><br>\n<label><input type='radio' name='rg' value='b'>beta</label><br>\n"); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Tell AQUtility about context: it can use this globally...which is really handy! AQUtility.setContext(getApplication()); // Load default preferences PreferenceManager.setDefaultValues(this, R.xml.preferences, false); findAllViewsById(); View.OnClickListener radioButtonListener = new View.OnClickListener() { public void onClick(View v) { RadioButton radioButton = (RadioButton) v; searchTypeTextView.setText("Searching for " + radioButton.getText()); } }; moviesSearchRadioButton.setOnClickListener(radioButtonListener); peopleSearchRadioButton.setOnClickListener(radioButtonListener); searchButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { String query = searchEditText.getText().toString(); if (moviesSearchRadioButton.isChecked()) { PerformFilmSearchTask task = new PerformFilmSearchTask(FilmSearchAppActivity.this); task.execute(query); } else if (peopleSearchRadioButton.isChecked()) { PerformPersonSearchTask task = new PerformPersonSearchTask(FilmSearchAppActivity.this); task.execute(query); } } }); int radioId = searchRadioGroup.getCheckedRadioButtonId(); RadioButton radioButton = (RadioButton) findViewById(radioId); searchTypeTextView.setText(radioButton.getText()); }
public void readNetwork() { ControlPanel cp_1 = new ControlPanel(this.network, "Data Selection", 1); this.network.addPanel(cp_1); ToggleNode Toggle_1 = new ToggleNode(this.network, "Toggle", 1, "Toggle"); this.network.addElement((Object) Toggle_1); SelectionNode Selector_1 = new SelectionNode(this.network, "Selector", 1, "Selector"); this.network.addElement((Object) Selector_1); RadioGroup pdown_Selector_1 = new RadioGroup(); Selector_1.addInteractor(pdown_Selector_1); pdown_Selector_1.setStyle(1); pdown_Selector_1.setLabelLines(1); pdown_Selector_1.setLabel("Main Plot"); pdown_Selector_1.setVertical(); Selector_1.setBounds(pdown_Selector_1, 0, 0, 204, 108); pdown_Selector_1.setOutputType(BinaryInstance.INTEGER); cp_1.addInteractor(pdown_Selector_1); Vector Selector_1_vn = new Vector(3); Vector Selector_1_vo = new Vector(3); Selector_1_vn.addElement("food group"); Selector_1_vo.addElement("0"); Selector_1_vn.addElement("item"); Selector_1_vo.addElement("1"); Selector_1_vn.addElement("unit"); Selector_1_vo.addElement("3"); Selector_1.setValues(Selector_1_vn, Selector_1_vo); Selector_1.selectOption(1); PickNode Pick_1 = new PickNode(this.network, "Pick", 1, "Pick_1"); this.network.addElement((Object) Pick_1); WebOptionsNode WebOptions_10 = new WebOptionsNode(this.network, "WebOptions", 10, "WebOptions"); this.network.addElement((Object) WebOptions_10); ImageNode Image_2 = new ImageNode(this.network, "Image", 2, "Image"); this.network.addElement((Object) Image_2); Image_2.setInputValueString(5, "[1.92754 1.8494 0]"); Image_2.setInputValueString(6, "[1.92754 1.8494 27.9747]"); Image_2.setInputValueString(7, "14.9916"); Image_2.setInputValueString(10, "[0 1 0]"); Image_2.setInputValueString(41, "pick"); Image_2.setInputValueString(42, "Pickable Plot"); Image_2.addInputArc(49, WebOptions_10, 1); WebOptionsNode WebOptions_11 = new WebOptionsNode(this.network, "WebOptions", 11, "WebOptions"); this.network.addElement((Object) WebOptions_11); ImageNode Image_3 = new ImageNode(this.network, "Image", 3, "Image"); this.network.addElement((Object) Image_3); Image_3.setInputValueString(5, "[6.92754 4.52749 0]"); Image_3.setInputValueString(6, "[6.92754 4.52749 56.3749]"); Image_3.setInputValueString(7, "30.2113"); Image_3.setInputValueString(10, "[0 1 0]"); Image_3.setInputValueString(41, "none"); Image_3.addInputArc(49, WebOptions_11, 1); WebOptionsNode WebOptions_12 = new WebOptionsNode(this.network, "WebOptions", 12, "WebOptions"); this.network.addElement((Object) WebOptions_12); ImageNode Image_4 = new ImageNode(this.network, "Image", 4, "Image"); this.network.addElement((Object) Image_4); Image_4.setInputValueString(5, "[3.07962 8.15925 2.74122]"); Image_4.setInputValueString(6, "[36.347 -19.6507 26.44]"); Image_4.setInputValueString(7, "26.481"); Image_4.setInputValueString(10, "[-0.387822 0.283476 0.877061]"); Image_4.setInputValueString(41, "none"); Image_4.addInputArc(49, WebOptions_12, 1); }
void select() { button.setSelection(true); parent.itemSelected(this); }
public void setImage(Image image) { checkWidget(); button.setImage(image); parent.layout(new Control[] {button}); }
void deselect() { button.setSelection(false); parent.itemSelected(this); }
private static int checkIndex(RadioGroup parent, int position) { if (position == -1) return parent.getItemCount(); if (position < 0 || position > parent.getItemCount()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); return position; }
private void handleSelection(Event event) { parent.itemSelected(this); }
@SuppressWarnings("ConstantConditions") public static void setEventListener( Object handler, ViewFinder finder, DoubleKeyValueMap<Object, Annotation, Method> value_annotation_method_map) { for (Object value : value_annotation_method_map.getFirstKeys()) { ConcurrentHashMap<Annotation, Method> annotation_method_map = value_annotation_method_map.get(value); for (Annotation annotation : annotation_method_map.keySet()) { try { Method method = annotation_method_map.get(annotation); if (annotation.annotationType().equals(OnClick.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; view.setOnClickListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnLongClick.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; view.setOnLongClickListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnFocusChange.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; view.setOnFocusChangeListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnKey.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; view.setOnKeyListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnTouch.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; view.setOnTouchListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnItemClick.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; ((AdapterView<?>) view) .setOnItemClickListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnItemLongClick.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; ((AdapterView<?>) view) .setOnItemLongClickListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnChildClick.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; ((ExpandableListView) view) .setOnChildClickListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnGroupClick.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; ((ExpandableListView) view) .setOnGroupClickListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnGroupCollapse.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; ((ExpandableListView) view) .setOnGroupCollapseListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnGroupExpand.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; ((ExpandableListView) view) .setOnGroupExpandListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnCheckedChange.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; if (view instanceof RadioGroup) { ((RadioGroup) view) .setOnCheckedChangeListener(new ViewCommonEventListener(handler, method)); } else if (view instanceof CompoundButton) { ((CompoundButton) view) .setOnCheckedChangeListener(new ViewCommonEventListener(handler, method)); } } else if (annotation.annotationType().equals(OnPreferenceClick.class)) { Preference preference = finder.findPreference(value.toString()); if (preference == null) break; preference.setOnPreferenceClickListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnPreferenceChange.class)) { Preference preference = finder.findPreference(value.toString()); if (preference == null) break; preference.setOnPreferenceChangeListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnTabChange.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; ((TabHost) view).setOnTabChangedListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnScrollChanged.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; view.getViewTreeObserver() .addOnScrollChangedListener(new ViewCommonEventListener(handler, method)); } else if (annotation.annotationType().equals(OnScrollStateChanged.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; Method method0 = null, method1 = null; ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value); for (Annotation a : a_m_map.keySet()) { if (a.annotationType().equals(OnScrollStateChanged.class)) { method0 = a_m_map.get(a); } else if (a.annotationType().equals(OnScroll.class)) { method1 = a_m_map.get(a); } } ((AbsListView) view) .setOnScrollListener(new ViewCommonEventListener(handler, method0, method1)); } else if (annotation.annotationType().equals(OnItemSelected.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; Method method0 = null, method1 = null; ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value); for (Annotation a : a_m_map.keySet()) { if (a.annotationType().equals(OnItemSelected.class)) { method0 = a_m_map.get(a); } else if (a.annotationType().equals(OnNothingSelected.class)) { method1 = a_m_map.get(a); } } ((AdapterView<?>) view) .setOnItemSelectedListener(new ViewCommonEventListener(handler, method0, method1)); } else if (annotation.annotationType().equals(OnProgressChanged.class)) { View view = finder.findViewById((Integer) value); if (view == null) break; Method method0 = null, method1 = null, method2 = null; ConcurrentHashMap<Annotation, Method> a_m_map = value_annotation_method_map.get(value); for (Annotation a : a_m_map.keySet()) { if (a.annotationType().equals(OnProgressChanged.class)) { method0 = a_m_map.get(a); } else if (a.annotationType().equals(OnStartTrackingTouch.class)) { method1 = a_m_map.get(a); } else if (a.annotationType().equals(OnStopTrackingTouch.class)) { method2 = a_m_map.get(a); } } ((SeekBar) view) .setOnSeekBarChangeListener( new ViewCommonEventListener(handler, method0, method1, method2)); } } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } } } }
public void setText(String string) { checkWidget(); button.setText(string); parent.layout(new Control[] {button}); }