SherlockMapActivity and onTap Event - android-mapview

I'm using this plugin:
https://github.com/JakeWharton/ActionBarSherlock-Plugin-Maps/downloads
To have MapViewActivity inside ABS.
My probleme is I want to detect the onTap event on the map, not on the overlay and the onTap method doens't seems to be present in the SherlockMapActivity.class
How to do it ?
Thanks.

SherlockMapActivity is just an extension of MapActivity that add the capabilities of ActionBarSherlock to the MapActivity. However, it doesn't add an onTap method and MapActivity doesn't provide one either.
I guess what you are trying to detect a tap on the MapView. Several methods exists in order to do so. One of my favorite is to add a custom Overlay that does nothing but detects the tap. This Overlay has to be added at the first overlay in the getOverlays()'s Listin order to have its onTap method called after all other Overlays

Related

Xamarin iOS : How to detect the tableview scroll

I want to detect the scroll of tableview in my class. I used decelerationEnded method of UITableViewDelegate but it got crashed.
Ideally you should be using a UITableViewSource assigned to your UITableView.Source property. You no longer require a delegate class, you can override all of the necessary methods within the source, which is the currently preferred method of achieving the result your after. You are most likely looking to override the method called 'Scrolled' within the UITableViewSource. However I would suggest making use of 'DecelerationEnded' as well if you're trying to do something depending on if your scroll view is at the 'bottom' or 'top' of the UITableViews content (That's just a little tip based off of some experience with this in a recent project.)

MonoTouch.Dialog change DialogViewController style

Is this possible to apply new style to already created DialogViewController? In one of my views I need to clear root and change from grouped to plain view.
Just setting style to new one doesn't do anything, so I'm not sure if I need to call some refresh method or this is not possible at all.
Found out looking at Monotouch.Dialog code that you need to call TableView.LoadView for this to happen.

Create Custom view in Android

I need to create a Custom view in android which will have dynamic text like price, address etc. and also an ImageView inside it as shown in the image below. I tried to find google some tutorial for custom view but didn't find something satisfactory to do all these things. I also need to use onClick event on this view. Please guys, some code would be of great help. I'm a novice to android. I read google tutorial to create custom view but couldn't implement this.
https://lh4.ggpht.com/HmwmRTx3g9ddkHbgvZXpZOB3Am-O9OQARQ2qpxJ16zTDZbG57CmvgxUC75sGFzC3cqrH
Thanks for attention.
This is called Custom Overlay for MapView.
You can check example and implement as per your requirement - Android MapView Balloons
You can use FrameLayouts. It is very simple to use. FrameLayout can add several views on top of each other. It creates a stack of the views. Just add whatever views you want to inside FrameLayout and use the property setVisibility() to control when to show which view.

MonoTouch.Dialog: Dismissing a Keyboard

Using the Reflection API to auto generate a UI.
How can I dismiss the keyboard when the user selects a new field, or if they choose a field which generates a new view to pick from. In the later case, when the user returns to the first screen, the old keyboard is still there.
UIView.EndEditing(bool force);
The above will hide the keyboard for you without needing to know who the first responder is. I haven't done much with the reflection API but you should be able to call that on the view when an element is selected.
Apple Docs -- endEditing:
Clarification for those initially struggling with the MonoDialog portion of the question:
The EndEditing method is not available on DialogViewControllers objects directly (who inherit from UITableViewControllers). You should be calling EndEditing(bool) on the View of a DialogViewController and not trying to call EndEditing(bool) on the actual DialogViewController itself.
For clarification:
DialogViewController dc;
dc.View.EndEditing(true);
Note:
UIView objects include the EndEditing(bool) method, but UITableViewControllers do not inherit from UIView so the EndEditing method is not available on the controller itself. UITableViewControllers contain a view object, call EndEditing on that view object.
Check the ResignFirstResponder method. This one should help you I guess.

MVC basics: Should I add a UIViewController, a Delegate or a Source to my custom view?

my question is about view controllers, delegates and all that in general. I feel perfectly comfortable with UIView, UIViewController, Delegates and Sources, like UITableView does for instance. It all makes sense.
Now I have implemented my first real custom view. No XIBs involved. It is an autocomplete address picker very much like in the Mail application. It creates those blue buttons whenever a recipient is added and has all the keyboard support like the original.
It subclasses UIView. There is no controller, no delegate, no source. I wonder if I should have either one of those? Or all, to make it a clean implementation.
I just cannot put my finger on the sense a view controller would make in my case. My custom view acts much like a control and a UIButton doesn't have a controller either.
What would it control in my view's case?
Some of my thoughts:
For the source: currently the view has a property "PossibleAutocompleteRecipients" which contains the addresses it autocompletes. I guess this would be a candidate for a "source" implementation. But is that really worth it? I would rather pass the controller to the view and put the property into the controller.
The selected recipients can be retrieved using a "SelectedRecipients" property. But views should not store values, I learned. Where would that go? Into the controller?
What about all the properties like "AllowSelectionFromAddressBook"? Again, if I compare with UIButton, these properties are similar to the button's "Secure" property. So they are allowed to be in the view.
The delegate could have methods like "WillAddRecipient", "WillRemoveRecipient" and so on and the user could return TRUE/FALSE to prevent the action from happening. Correct?
Should I maybe inherit from UIControl in the first place and not from UIView?
And last but not least: my custom view rotates perfectly if the device is rotated. Why don't all views? Why do some need a controller which implements ShouldAutoRotateToDeviceOrientation()?
Does it make sense what I wrote above? In the end I will provide the source on my website because it took me some time to implement it and I would like to share it as I have not found a similar implementaion of the Mail-App-like autocomplete control in MonoTouch.
I just want to learn and understand as much as possible and include it in the source.
René
I can answer part of your question.
I just cannot put my finger on the
sense a view controller would make in
my case
The ViewController is responsible for handling the View's state transitions (load, appear, rotate, etc) These transitions are used mainly when you use a navigation component (UINavigationViewController, UITabBarController). These components needs to received a ViewController that will handles the view's transitions.
For exemple, when you push a ViewController on a UINavigationViewController, it will cause the ViewDidLoad, ViewWillAppear, ViewDidAppear. It will also cause the ViewWillDisappear, ViewDidDisappear of the current ViewController.
So, if your application has only one portrait view, you don't need a ViewController. You can add your custom view as a subview of the main window.

Resources