In my Vaadin 8 application, I have a TabSheet, that contains several views. When I override the enter method in the first view of my TabSheet, and then I proceed to enter the view on my application, the method doesn't get called.
Do you have a Navigator, and have you registered the views for it? Navigator's navigateTo is what calls the enter. Registering views happens along these lines:
navigator.addView("", new InitialView());
navigator.addView("second", new SecondView());
Navigation also updates the URI fragment in your browser, and makes it possible to bookmark specific views and enter them via direct URL. See e.g. https://vaadin.com/docs/v8/framework/advanced/advanced-navigator for more information about Navigator.
TabSheet isn't the most trivial thing to use with Navigator and I'm afraid I don't have a ready-made example at hand, but I think it should be doable with a custom ViewDisplay and maybe SelectedTabChangeListener.
If you aren't interested in the Navigator approach, I suppose you could replace the View+enter with something along these lines, although if you need to know the previously selected tab you'll need to keep track of it yourself since this particular event isn't very informative:
tabSheet.addSelectedTabChangeListener(e -> {
((MyClass) tabSheet.getSelectedTab()).myMethod());
});
So in my app I have a registration form used to register other users. In my app I have 3 ranks (Admin, Patient, HCP). In the 'New HCP' form I want to hide something that is in my .xml file for the TextView. I am well aware of setVisibilty(View.GONE); but this doesn't work for my options because I have the boxes in a Constraint Layout.
My Question is:
How do I hide the whole box including its contents?
I tried this (but it only hid the contents and left the drawable box behind:
TextView consent_TextView = (TextView) findViewById(R.id.Register_text_Activity_consent);
consent_TextView.setVisibility(View.GONE);
TextView remind_TextView = (TextView) findViewById(R.id.Register_text_Activity_remind);
remind_TextView.setVisibility(View.GONE);
Please remember that I want to change this in Java not XML because if I do it in XML I will hide the box for everyone. Thanks!
As said in the comments, you can get a reference to the box you want to set the visibility either through View#getParent() or you can set its id programatically via View#setId(), bind it and set its visibility.
I am working on an RCP application, in which I want to connect 2 views so that when I click a node of TreeViewer in view1 the TableViewer in view2 must be populated.
I have 2 view classes namely ViewPart1(TreeViewer) and ViewPart2(TableViewer).
Can anyone help me out in achieving this?
Use the selection service.
In the view (view1) which is providing the selection you must set the selection provider to be the tree:
getSite().setSelectionProvider(viewer);
where viewer is a TreeViewer (or TableViewer) or something else that implements ISelectionProvider.
In the view which wants to see selections set up a listener:
ISelectionService selService = getSite().getWorkbenchWindow().getSelectionService();
selService.addSelectionListener(listener);
where listener is something that implements ISelectionListener.
Note: Your listener will be told about selection changes everywhere, it is up to you to sort out which ones you want to react to.
I want to develop an Android app, where start page of the app GUI, will contain 4 vertical layouts in the main layout. Now, in each layout, I want to add buttons/slider dynamically from the app (instead of adding buttons/slider dynamically in the source code). That means, initially all these 4 layouts will be blank and when user will select any button or slider in another layout, to add it in any of this 4 layouts, the button or slider will be added in that layout. User will be able to add max 10 views in any vertical layout and the views can be either button, slider or custom view.
My attempt:
First I tried to create 4 vertical layout under the main layout for startup page and I got succeed.
I also find after searching that its possible to add views dynamically in layouts in android.
dynamically adding a view to activity layout
But most examples, add views dynamically in android by running loops, instantiating the desired view class and then add it in the main layout. Although, in this way, views are added dynamically in the layout, it is done by modifying the source code.
Is it possible to write the source code in a way, so that it can be done directly from the app? So that when user will click on Add a slider in "layout 1", a slider will be added in layout 1 and then again, when the user will click on "Add a button" in layout 1, a button will be added at the end of the slider. User will be able to customize button or slider properties. Also, if the user change the value of the slider, the app will remember its value.
Now, next time, when the app will be opened, those views will be there in the layouts, they will not be deleted and the values will remain unchanged (for example, a ticked check box will remain ticked), so I think I also need some kind of storage or properties manager.
My question is, is it possible to do this in android (because I never seen such apps in android) and if possible, any idea, how can I implement it?
I am totally new to android, so my knowledge is limited but I completed the basic tutorials on android app development and I have plugin development experience in eclipse.
Thanks a lot in. I will highly appreciate your help.
Of course it is possible:
Every layout (like LinearLayout, RelativeLayout etc.) extends the ViewGroup-class, which offers the addView-method.
To add a new view (like a Slider) to one of your layouts, just instantiate it programmatically (via new) in your activity and assign the appropriate LayoutParams to it
To store the state of user added content, it is the easiest to use SharedPreferences - a simple key-value-store which holds data over the application's lifecycle
Yes. This is possible. To create the Views dynamically, you simply have to either extend the class of the View or just say new Button(Context, AttributeSet); (Not only for Button's every View has a constructor that takes an attribute set and a context).
Using Layout.addView() you can add any View to the Layout.
Using SharedPreferences you can indicate what View belongs in what Layout.
If you decide to extend the View's class, make sure not to do too much in it. I tried that once and it just gave me an OOM (OutOfMemory Error) because I had a ton a Views trying to do stuff at the same time.
After the start of my application the coolbar is loaded and the first item is selected automatically. I don't want that. Is it possible to remove this selection?
Screenshot: http://i.imgur.com/q15X1.png
Thanks in advance.
I think this is because that button (or rather the toolbar) currently has the focus. To remove the focus you have to set it to another control. Did you implement the setFocus() method of your "Übersicht" view?