How to select Radio button in Uiautomator - android-uiautomator

How to select Radio button in Uiautomator?
Eg: i've a radio button to switch on my wireless in my LG phone.How to select these radio buttons.

please use
UiObject dataValue = new UiObject(new UiSelector().className(RadioButton.class.getName()).index(0));
dataValue.click();

Related

Mutually exclusive Radio buttons for toggling between two group boxes

I want to achieve:
On init () both group boxes are hidden and both GRP A and GRP B radio button enabled [ACHIEVED].
I click on GRP A radio button , GRP box 1 displayed GRP B radio button grayed out. [ACHIEVED].
Uncheck GrP A radio button GRP Box 1 hides both GRP A and B radio buttons enabled [FAILING : NOT ABLE
TO UNCHECK THE SELECTED RADIO BUTTON].
Check Group Box B radio button same process happens as described above.
You are trying to 'break' the concept of radio-buttons. The "GRP A" and "GRP B" buttons (assuming they are in the same 'group') will automatically be mutually exclusive, so long as both are enabled - you have to have one of the buttons checked (even if there are 3 or more in the same group). Thus, in your case, to un-check "GRP A" you will need to check "GRP B".
Unless, of course, you override the default handling of those radio-buttons.
To override the default handling, you can provide a handler for the BN_CLICKED message from the each of the "GRP A" and "GRP B" buttons, and explicitly set the state of both buttons to unchecked and enabled in that handler. You would also put code in that handler to hide the two groups (or show one, when appropriate).
Here's an outline of possible code, assuming your parent dialog is derived from CDialog and the IDs of the two radio-buttons are IDC_GRPA and IDC_GRPB:
BEGIN_MESSAGE_MAP(MyDialog, CDialog)
ON_CONTROL(BN_CLICKED, IDC_GRPA, &MyDialog::OnClickA)
ON_CONTROL(BN_CLICKED, IDC_GRPB, &MyDialog::OnClickB)
//... other handlers and message map entries
END_MESSAGE_MAP()
// Handler for a "GRP A" button click:
void MyDialog::OnClickA()
{
UINT checked = IsDlgButtonChecked(IDC_GRPA);
if (checked == BST_CHECKED) {
GetDlgItem(IDC_GRPB)->EnableWindow(TRUE); // ENABLE other button
CheckDlgButton(IDC_GRPA, BST_UNCHECKED); // Clear this button
CheckDlgButton(IDC_GRPB, BST_UNCHECKED); // and the other one
// Now do the required stuff to HIDE the group boxes...
}
else {
CheckDlgButton(IDC_GRPA, BST_CHECKED); // Check this button
GetDlgItem(IDC_GRPB)->EnableWindow(FALSE); // DISABLE other button
// Now do the required stuff to SHOW the "GrpBox 1" controls ...
}
}
// The "OnClickB()" handler will be very similar to the above, but with the IDs 'reversed'.
Please feel free to ask for any further clarification and/or explanation.

How to pass Orbeon dropdown control selected value to script

The following code works for radio buttons.
<xf:select1 id="User-Status-control" appearance="full" bind="User-Status-bind">
<xf:itemset ref="instance('User-status')/item">
<xf:label ref="#value"/>
<xf:value ref="#name"/>
</xf:itemset>
<xf:action ev:event="xforms-value-changed">
<xxf:script>
var op1 = ORBEON.xforms.Document.getValue(this);
alert("op1 : " + op1); // print the selected radio button ID.
</xxf:script>
</xf:action>
but it does not works for dropdown
<xf:select1 id="User-Status-control" bind="User-Status-bind" appearance="dropdown">
How can I get the value of an Orbeon dropdown control?
Because <fr:dropdown> AKA <xf:select1 appearance="dropdown"> is a compound control, you have to go search for the nested .xforms-select1 control. Something like:
ORBEON.xforms.Document.getValue(ORBEON.jQuery(this).find('.xforms-select1')[0])
I have updated the doc to reflect this.

E4 RCP How to set selection of ToolBarItem that contains Radio Buttons

In Eclipse E4 (Luna), using the application model to create parts, handlers, commands, handled menu items etc, (these are not created programatically). I have a toolbar. This contains a sub-Menu item called "Filter" that contains another sub-menu of two filters. The two filters are two Handled Menu Items which are set up as "Radio" Buttons.
When I select the appropriate in the UI of my running app from the selection, the Radio button switches just fine to the selected Item. However I would like this selection to update (deselecting one Radio button and selecting the appropriate radio button of the handled menu item) when my ViewPart changes through other UI selection. Currently my ViewPart updates, but the Radio buttons are on the same previous selection through the UI.
Is there a way in which I get access both Handled Menu Item's IDs and set the selection (one to false, the other to true) when the viewer is updated.
Image of design is attached below:
Hierarchy of the application model is as follows:
Thanks in advance,
Marv
You can use the model service to find menu items. Use something like:
#Inject
EModelService modelService;
#Inject
MApplication app;
List<MMenuItem> items = modelService.findElements(app, "menu item id", MMenuItem.class, Collections.emptyList(), EModelService.IN_MAIN_MENU);
Once you have the MMenuItem you can call the setSelected(boolean) method to change the selection.
To find a menu item which is in a Part menu use:
modelService.findElements(app, "menu item id", MMenuItem.class, Collections.emptyList(), EModelService.IN_PART);
(IN_PART argument instead of IN_MAIN_MENU).
You could also specify the MPart rather than the Application as the first argument to findElements which may speed up the search.
For menus as a child of a Tool Bar Item it appears that the model services cannot find these directly. However you can find the Tool Bar Item and look at the menu yourself:
List<MToolItem> items = modelService.findElements(app, "tool bar item id", MToolItem.class, Collections.emptyList(), EModelService.IN_PART);
MToolItem item = items.get(0);
MMenu menu = item.getMenu();
List<MMenuElement> children = menu.getChildren();
... search menu elements
I solved this by starting with MPart PartID and drilling down to the HandledMenuItems on which I wanted to set the Radio Button selections, then setting the selection property for each individual HandledMenuItem.
This can probably be refactored to be more concise, but I've left the code with each step to have the solution easier to read.
BTW, in every instance / combination of the EModelService methods, the list returned a size of 0. So I'm not certain if that will work for what I'm trying to achieve. The following does work, although I'm not certain it is the most efficient means.
I hope this helps others.
// Get view part
MPart viewPart = _partService.findPart("part_id");
// get list of all menu items from the Part
List<MMenu> viewPartMenu = viewPart.getMenus();
// Get list of ViewMenus from viewPartMenu there is only one View Menu so it will be index 0
MMenu viewMenu = viewPartMenu .get(0);
// Get list of MMenuElements from the viewMenu - the children in the view menu
List<MMenuElement> viewMenuElements = viewMenu.getChildren();
// This gets me to the 2 HandledMenuItems
// Upper Most HandledMenuItem Radio Button is at viewMenuElements index 0. This is cast to MHandledMenuItem
MHandledMenuItem upperHandledMenuItem = (MHandledMenuItem) viewMenuElements.get(0);
// Set Selection
upperHandledMenuItem.setSelected(false);
// Lower Most HandledMenuItem Radio Button is at viewMenuElements index 1. This is cast to MHandledMenuItem
MHandledMenuItem lowerHandledMenuItem = (MHandledMenuItem) viewMenuElements.get(1);
// Set selection
lowerHandledMenuItem.setSelected(true);

How to get an info from DGV when mouse is on?

If I have a datagridview and I have a button and I want that the moment I press this button, I'll get string from the column the mouse is on.
For getting a current selected cell from datagridview("marked cell"):
mydatagridview.CurrentCell
and get a value of this cell
mydatagridview.CurrentCell.Value
For be sure: check if CurrentCell exists(C#)
if(mydatagridview.CurrentCell != null)
String selectedValue = mydatagridview.CurrentCell.Value.Tostring();
MSDN DataGridView documentation

Tabbing between radio buttons in VB6

I have a form which consists of six radio buttons within a frame which are mutually exclusive and one command button.
I already gave different tab-index to each radio button but at the run time by pressing tab focus skipped out of the radio buttons.
so how to give focus to another radio button by pressing TAB?
As others have said above this is intended behaviour. If you really wish to achieve this then the only way I can think to do this is place each radio button on a separate picture box (BorderStyle = None, TabStop = False). This will then work but you won't be able to use arrow keys to move between the radio buttons, only tabbing.
Private Sub Option1_KeyPress(KeyAscii As Integer)
If KeyAscii = 9 Then
Option2.SetFocus
End If
End Sub
KeyAscii=9 is the code for the Tab key. But you must do it for all of your radio buttons.
If you add your radio buttons belonging to the same radio button having indices 0, 1, 2 you can do it like this:
Private Sub Option1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 9 Then
If Index < Option1.Count - 1 Then
Option1(Index + 1).SetFocus
Else
Option1(0).SetFocus
End If
End If
End Sub

Resources