How can I change the spinnerMode when the button is pressed?
I mean mainly the method of implementing the change to the spinner and the rest I hope that I can do it :)
Let's say I have a spinner like below
val spinner= findViewById<Spinner>(R.id.Spinner)
I know you can apply something like this, but how do you implement it in the spinner shown above?
val setSpinnerMode = Spinner(this, null, android.R.style.Widget_Spinner, Spinner.MODE_DROPDOWN)
Or maybe someone has a better idea than the one shown above :)
in kotlin you can try this
val spinner = findViewById<View>(R.id.spinner) as Spinner
val adapter = ArrayAdapter(this#MainActivity,
R.layout.simple_spinner_dropdown_item, list)
adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item)
spinner.adapter = adapter
spinner.performClick()
Related
When i want to get my text
var edittext1: EditText = findViewById(R.id.edittext1);
var text = edittext1.text.toString()
Then the string is always empty
Please check if you have a synthetic import of your activity: e.g :
import kotlinx.android.synthetic...
If you do, it might seem like the activity is confused between the variable name and id of the field. If you have the synthetic import, you don't need the findViewById,
You can just say something like val edtText = edittext1.text.toString()
How can I get widget properties given that I know the URL, language and version I want of a page. I am trying to get a property of a widget instance from a completely different project in the same solution. Is this possible?
Incase some one needs it in future. I think I have figured it out now. Remember to resolve the url before use.
TreeProvider tree = new TreeProvider();
TreeNode staticNode = tree.SelectSingleNode(siteName, url, culture);
PageInfo pi = CMSWebPartPropertiesPage.GetPageInfo(staticNode.NodeAliasPath, staticNode.DocumentPageTemplateID, culture);
PageTemplateInstance templateInstance = pi.DocumentTemplateInstance;
WebPartInstance widgetInstance = templateInstance.GetWebPart(widgetName);
I want to change my start navigation fragment based on a condition. My start fragment could be fragment one or two. Is there a way to implement it?
Check out this question and its solution // Also added Java code here
Just converted Kotlin code to Java
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.home_nav_fragment); // Hostfragment
NavInflater inflater = navHostFragment.getNavController().getNavInflater();
NavGraph graph = inflater.inflate(R.navigation.nav_main);
graph.setDefaultArguments(getIntent().getExtras());
graph.setStartDestination(R.id.fragment1);
navHostFragment.getNavController().setGraph(graph);
navHostFragment.getNavController().getGraph().setDefaultArguments(getIntent().getExtras());
NavigationView navigationView = findViewById(R.id.navigationView);
NavigationUI.setupWithNavController(navigationView, navHostFragment.getNavController());
Check out this question and it's solution
I have also added a comment below the answer to clear it up a bit.
I have an application with grid of records and button insert. After clicking insert, there is a form, where you fill in data and click Ok for adding new record to the grid. After clicking Ok, there is validation which fires dialog with error informations, if any of the text fields do not match validation rules. Is there any posible way to test text on the dialog with textFx, if the dialog has no id?
This is an example for Alert based dialog:
In your test:
alert_dialog_has_header_and_content(
"Removing 'Almaty' location", "Are you sure to remove this record?");
In you helper test class:
public void alert_dialog_has_header_and_content(final String expectedHeader, final String expectedContent) {
final javafx.stage.Stage actualAlertDialog = getTopModalStage();
assertNotNull(actualAlertDialog);
final DialogPane dialogPane = (DialogPane) actualAlertDialog.getScene().getRoot();
assertEquals(expectedHeader, dialogPane.getHeaderText());
assertEquals(expectedContent, dialogPane.getContentText());
}
private javafx.stage.Stage getTopModalStage() {
// Get a list of windows but ordered from top[0] to bottom[n] ones.
// It is needed to get the first found modal window.
final List<Window> allWindows = new ArrayList<>(robot.robotContext().getWindowFinder().listWindows());
Collections.reverse(allWindows);
return (javafx.stage.Stage) allWindows
.stream()
.filter(window -> window instanceof javafx.stage.Stage)
.filter(window -> ((javafx.stage.Stage) window).getModality() == Modality.APPLICATION_MODAL)
.findFirst()
.orElse(null);
}
I know this issue is a little old and probably got fixed, but for documentation purpose in case someone else look for a fix for an issue alike, I see dialog.getDialogPane() in Dialog documentation, which would help lookup for specific controls inside the pane. So further on #plaidshirt query, we could retrieve buttons and input fields with:
dialog.getDialogPane().lookupAll()
Then narrow that down to buttons and input fields for example.
Each input field in the CKEditor dialogs are renamed with a unique number, but the number changes depending on what options are visible.
I need to reference 'txtUrl' which has an id something like #35_textInput.
So far I have discovered that something like this should work:
alert(CKEDITOR.instances.myElement.document.$.body.getId('txtUrl'));
But it doesn't. Please help.
#Rio, your solution was really close! This was the final solution:
var dialog = CKEDITOR.dialog.getCurrent();
dialog.setValueof('info','txtUrl',"http://google.com");
return false;
var dialog = this.getDialog();
var elem = dialog.getContentElement('info','txtUrl');
within an onchange part of an element I now use
dialog = this.getDialog();
alert(dialog.getContentElement('info', 'grootte').getInputElement().$.id);
and it gives 'cke_117_select' as a result. (It's a selectbox)
alert(dialog.getContentElement('info', 'txtUrl').getInputElement().$.id);
gives 'cke_107_textInput'.
I think this is what you (or other visitors to this page) are looking for.
SetValueOf still doesn't provide the id, which you may need if you want to do more than fill a text field with a certain text.