My app has a details screen like an AboutScreen. The height of all fields on the screen is more than the screen height, for all devices. I need to place the elements in a VerticalFieldManager with scrolling.
In the sublayout method, what x and y coordinates are given so that I can place every field one after other?
If you want to add the fields one after the other and enable scrolling, why would you override sublayout at all?
Instead just use new VerticalFieldManager mgr = VerticalFieldManager(Field.VERTICAL_SCROLL); and mgr.add(field1), mgr.add(field2), etc.
Alternatively, MainScreen defaults to using a VerticalFieldManager - so if your class extends MainScreen, ensure that your constructor calls super(VERTICAL_SCROLL); then you can just invoke ".add" directly.
Both cases will automatically handle vertical scrolling and offscreen placement. If the fields are all labelfields, make sure to set them to "focusable" -- otherwise the user won't be able to scroll.
Related
I'm using Xamarin with MvvmCross to create an iPad application. In this application I want to support rotation in such sense that the layout is adjusted automatically when the rotation event occurs.
I'm aware of the GetSupportedInterfaceOrientations and the ShouldAutorotate methods, which I have tried to override to catch the event and reset observable properties in the ViewModels I use. Also, the Views have been set up in two tries:
1) Setting up the control (i.e. a label) to be bound to the screen properties:
var theLabel = new UILabel(new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width, 30));
2) Setting up the control (i.e. a label) to be bound to the screen properties through observable ViewModel properties which are set in the GetSupportedInterfaceOrientations and ShouldAutorotate methods of the View. However, the value is not bound here, but just set:
var theLabel = new UILabel(new RectangleF(0, 0, ViewModel.TheLabelWidth, 30));
I have tried to set the width accordingly through a bindingset in a delaybind, but the width property is not able to be set in the .For(lambda expression) as I would expect.
Whatever the cause is, it seems that the interface is not redrawn. The value in the ViewModel does get set. Anyone any suggestions on this one?
Thanks in advance.
Why do you want to handle UI related tasks in the ViewModel? The main reason you should use MVVM pattern is to separate the logic from the UI. Logic goes to the ViewModel and the UI goes to the View. So you shouldn't put any UI measurement and rotation handling to the ViewModel since it's not part of the logic and can't be reused on other platforms.
BTW if you want to handle rotations automatically you should use constraints or use a tool that allows you to create automatic layouts (i.e. http://www.toptensoftware.com/xibfree/).
I suggest you read more about the MVVM pattern.
There should not be any UI related values \ properties in the view-model!
This means, no screen coordinates to position controls, no color values, no font names, absolutely nothing related to the UI!
The view-model should always be view and platform agnostic.
You should handle all the view related things in the platform specific view code (on iOS, UIViewController for example)
If you need to have specific UI related values (control position, visibility, etc) depending on the values from the view-model, then you should use a value-converter (read about them here https://github.com/MvvmCross/MvvmCross/wiki/Value-Converters)
Second, I don't understand exactly what you are trying to achieve with the code you posted, but make you sure you are using the iOS layout system correctly.Use the AutoLayout to position and size the controls which will make your UI look and work on any screen size, any iPhone and any iPad.
Yout viewmodel needs to send a message to your view with a messenger (like MvxMessenger)
I want to add vertical scroll feature to my own custom manager, but i am not getting it,
as of now i am passing style bits VERTICAL_SCROLL|VERTICAL_SCROLLBAR to the constructor
of my own custom manager
Please post your code
Call super on constructor if you are extending any other manager class
An easy fix is to nest your custom manager inside a VerticalFieldManager with scroll.
In my blackberry app I have multiple cases where I have a scrolling VerticalFieldManager. They all scroll and behave correctly, but I can't seem to get any of them to show the scroll bar arrows. This is the code I am using to initialize them (They are all roughly the same)
VerticalFieldManager manager = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH | VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.VERTICAL_SCROLLBAR);
Any ideas? I don't understand why they won't show up.
Thanks,
I figured it out!
It was because while I had a VerticalFieldManager that took up the entire screen (called primary), which was intialized without scroll, I didn't actually call super(Manager.NO_VERTICAL_SCROLL).
So if anyone else stumbled here with the same problem, I couldn't get my children Managers to show a scroll bar, untill I called super(Manager.NO_VERTICAL_SCROLL), even if the elements I wanted to scroll were in a manager that had NO_VERTICAL_SCROLL set.
The BlackBerry default scroll bar is two very small arrows (See the image below). My guess is you were expecting to see a rectangle down one side showing the percentage scrolled.
If this is the problem you might be interested in this more conventional implementation: http://supportforums.blackberry.com/t5/Java-Development/Implementing-a-standard-style-scrollbar-on-a-Blackberry-device/ta-p/504416
In my application I have an ordered sequence of bitmaps where I need to flip them right to left and left to right, based on whether the user clicked on the left or right of the screen after the bitmap loads.
I need to implement the click event on the screen only after the bitmap is painted to the screen.
This is a very vague question. If you are using a Screen object and simply drawing the bitmaps by overriding the paint() method, you just need to also override the touchEvent() method and handle that. But without any code it's hard to give you specific advice.
Suppose I have a VFM full of both focusable and non-focusable fields. Since most of them are spread out far apart, the movement from one focused field to another is jerky at best, even with NullFields in between. In other words, it just sets the current y position to the next focused field without smoothly scrolling the screen.
What I want to achieve is to be able to scroll at a fixed rate between fields, so it it doesn't just focus from one to another that instantaneously. After reading up on how to do this, it is a matter of overriding moveFocus and setting it via a TimerTask from an accessor method to set moveFocus, as per this link. However, I haven't seen a practical implementation of how to do this, complete with the routines that are called in the TimerTask's thread.
Is there any way to achieve this type of behavior?