I'm getting an error in my code.
the method setViewPort(int, int) cannot be defined for the type canvas.
I am trying to implement multi touch functionality on an ImageView, the intire class is far too long to put up here but if you require more information just comment.
#Override
protected void onDraw(Canvas canvas) {
if(layout) {
if(!viewSet) {
//line that's causing issue
canvas.setViewport(displayWidth, displayHeight);
viewSet = true;
}
can't figure out what the issue is, have all necessary imports etc.
Would it be the fact I'm using Android 4.0?
thanks.
Shaw
Here's the answer from Romain Guy from the Google Group:
"This method was removed because it had no effect whatsoever. It was a
remnant of an old and failed experiment."
Related
I have been working with DJI Mobile SDK for Android, making my own application by following this tutorial: https://developer.dji.com/mobile-sdk/documentation/android-tutorials/MediaManagerDemo.html
But i have to download all pictures at once at the start of my gallery, and i coudn't manage how to do it.
Is there any example showing how to do it?
I think it should happen at MainActivity.java from the MediaManagerDemo tutorial. Should i create getFiles() and put it alongside getThumbnails and getPreviews (on line 317)?
scheduler.resume(new CommonCallbacks.CompletionCallback() {
#Override
public void onResult(DJIError error) {
if (error == null) {
getThumbnails();
getPreviews();
}
}
});
Should i create a Callback for this? What else should i look out?
Thank you all in advance!
EDIT: I stopped and thinked calmly about this, and managed to solve this by creating a downloadAllFiles() method after getPreviews(), where it checks if the connection was succeed and calls downloadFileByIndex for each one of the items. I also implemented a way to check if there is already a file with the exact size on internal storage, to avoid unnecessary downloads.
If anyone is interested, heres my code on Github
Have you looked at the section in the tutorial on Downloading and Editing the Media files?
Is there a way or workaround to achieve custom image showing in app's recent history ?
I know the android activity already given for such case :
#Override
public boolean onCreateThumbnail (Bitmap outBitmap, Canvas canvas) {
// draw custom image here.
return true;
}
But unfortunately this method is never called.
So anyone knows how can possibly achieve that ?
Any ideas welcome.
I am trying to render a checkbox in a Xamarin Forms app. There is nothing rendered at runtime, as far as I can tell the renderer is not even getting called.
Does anyone understand what I am missing or doing incorrectly?
Here is my class in Forms:
public class LegalCheckbox : View
{
public LegalCheckbox ()
{
}
}
And my custom renderer class in Droid:
public class CheckBoxRenderer : ViewRenderer<LegalCheckbox, CheckBox>
{
protected override void OnElementChanged (ElementChangedEventArgs<LegalCheckbox> e)
{
base.OnElementChanged (e);
CheckBox control = new Android.Widget.CheckBox(this.Context);
control.Checked = false;
control.Text = "I agree to terms";
control.SetTextColor (Android.Graphics.Color.Rgb (60, 60, 60));
this.SetNativeControl(control);
}
}
Along with the Assembly Directive:
[assembly: ExportRenderer(typeof(demo.LegalCheckbox), typeof(demo.Droid.CheckBoxRenderer))]
Took your code and fired up a new project with it. The code appears to function fine.
Only thin I can think that might be causing you an issue is the location of you assembly attribute. I typically place them just above the namespace declaration in the same file as my renderer.
I threw what I created up on my github maybe you can spot the difference.
https://github.com/DavidStrickland0/Xamarin-Forms-Samples/tree/master/RendererDemo
#Thibault D.
Xlabs isn't a bad project but its basically just all the code the opensource community came up with during the first year or so of Xamarin.Forms life. Its not really "Their Labs projects" and considering how much of it is marked up with Alpha Beta and the number of bugs in their issues page it's probably best not to imply that the Xamarin company has anything to do with it.
I am not sure if that is the issue but it would make more sense to me if your LegalCheckbox would inherit from a InputView rather than View.
Also, even if Xamarin.Forms does not have a Checkbox control you can still have a look at their "Labs" project here:
https://github.com/XLabs/Xamarin-Forms-Labs/wiki/Checkbox-Control
(And I can actually see that they inherit from View...)
Update: Thx for the answers, problem solved.
Yes code is missing, I am using Mapsforge library.
It had nothing to do with anything else than a bad comparison in a sqlite lookup
which resulted no calling of toggleColor(). Now it works just fine!
Hi I am having trouble changing the color of a circle drawn on a canvas. The other color represents a different state of the circle.
It works fine with onTap i.e when I tap the circle on the screen, but when I try to do it programmatically like
circle.toggleColor() and then
circle.requestRedraw() nothing happens.
How can I make this work programmatically?
#Override
public boolean onTap(LatLong geoPoint, Point viewPosition, Point tapPoint) {
if (this.contains(viewPosition, tapPoint)) {
toggleColor();
this.requestRedraw();
return true;
}
return false;
}
#Override
private void toggleColor() {
if (this.getPaintFill().equals(LongPressAction.GREEN)) {
this.setPaintFill(LongPressAction.RED);
} else {
this.setPaintFill(LongPressAction.GREEN);
}
}
Thx for answering
Yes code is missing in the snippet, I am using Mapsforge library.
It had nothing to do with anything else than a bad comparison in a sqlite lookup which resulted no calling of toggleColor(). Too much time spent on chasing that stupid mistake...
Now it works just fine!
I saw online this code used a lot:
public void onAccelerometerChanged(final AccelerometerData myAccelerometerData) {)
When I try to use it, eclipse will not recognize the AccelerometerData class.
I'm having a hard time:
Detecting tilt.
Using it to change the worlds physics with box2d.
It would help me if anyone could show me ways of detecting tilting and using it.
Thank you.
You can see this code used in the PhysicsExample where it is used to change the center of gravity.
You must use the same code branch as the one in the example you have found. Notice that I linked GLES2-AnchorCenter branch version of the PhysicsExample. This branch is the newest. There is no AccelerometerData class. It has been renamed to AccelerationData.
Tilting (phone orientation) can be detected in a similar fashion. You have to call the following methods in your Activity and pass the correct listener.
protected boolean enableOrientationSensor(final IOrientationListener pOrientationListener) {
return this.mEngine.enableOrientationSensor(this, pOrientationListener);
}
protected boolean enableOrientationSensor(final IOrientationListener pOrientationListener, final OrientationSensorOptions pLocationSensorOptions) {
return this.mEngine.enableOrientationSensor(this, pOrientationListener, pLocationSensorOptions);
}