I'm trying to add fullscreen functionality to my program but I couldn't get it to work. I'm trying
Display.setFullscreen(true);
I tried changing its position to above where I create the display or where I set the displaymode, but still not working. Any help about this?
From my experience the DisplayMode needs to support it. You can try this:
DisplayMode displayMode = null;
DisplayMode[] modes = Display.getAvailableDisplayModes();
for (int i = 0; i < modes.length; i++)
{
if (modes[i].getWidth() == width
&& modes[i].getHeight() == height
&& modes[i].isFullscreenCapable())
{
displayMode = modes[i];
}
}
After doing this your Display.setFullscreen(true) should work
I know this question is quite (5 years) old, but there may still be people looking for a solution to this question.
The simplest way is to do:
Display.setDisplayModeAndFullscreen(Display.getDesktopDisplayMode());
Which will put your display in fullscreen for you. No need for setFullscreen() with this either.
Related
I capture a image by camera in emulator and it was saved as:
"/storage/emulated/0/Download/IMG_1582623402006.jpg"
I am trying to display this image in < ImageView > as the following:
Bitmap finalBitmap = BitmapFactory.decodeFile("/storage/emulated/0/Download/IMG_1582623402006.jpg");
holder.image.setImageBitmap(scaledBitmap);
but it shows that "finalBitmap" is empty. What have I missed?
Thanks in advance!
You posted this over a year ago, so it may be too old at this point.
It appears that you are using two variables for your bitmaps: finalBitmap and scaledBitmap and not referencing the proper one in the setImageBitmap command.
Instead, have you tried this?
holder.image.setImageBitmap(finalBitmap);
Not totally sure, but adding some attributes in "options" seems make it work in emulator:
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = true;
options.inSampleSize = 5;
Bitmap scaledBitmap = BitmapFactory.decodeFile(/storage/emulated/0/Download/IMG_1582623402006.jpg, options);
holder.image.setImageBitmap(scaledBitmap);
I have subclassed UIRefreshControl to make my own, and I can manage everything except one thing :
The default spinner is always visible, and is of course in the middle of everything I've done in my custom implementation.
I can't find the spinner property or whatever it is I need to put to a clear color, can anyone help me on this?
To hide spinner loader in a UIRefreshControl, set the .tintColor property to a clear color.
e.g. (Swift):
mRefreshControl.tintColor =.clear
For 2023, .tintColor = .clear works fine.
Historic answer:
Swift 4, Swift 5
Bug fix
From time to time only this code doesn't work properly:
refreshControl.tintColor = .clear – first reload shows the indicator :(
This fixes this bug:
refreshControl.tintColor = .clear
refreshControl.subviews.first?.alpha = 0
Override didMoveToSuperview to hide the spinner's superview.
Swift version:
override func didMoveToSuperview() {
super.didMoveToSuperview()
guard let _ = superview else { return }
self.subviews.first?.alpha = 0 // set hidden = true did not work
}
Objective-C version:
- (void)didMoveToSuperview {
[super didMoveToSuperview];
if (self.superview != nil && self.subviews.count > 0) {
self.subviews[0].alpha = 0;
}
}
You may want to do more checks rather than just using the first subview.
I am trying to make a (new in 10.10) NSSplitViewItem collapse and uncollapse whilst moving its containing window so as to keep the whole thing "in place".
The problem is that I am getting a twitch in the animation (as seen here).
The code where I'm doing the collapsing is this:
func togglePanel(panelID: Int) {
if let splitViewItem = self.splitViewItems[panelID] as? NSSplitViewItem {
// Toggle the collapsed state
NSAnimationContext.runAnimationGroup({ context in
// special case for the left panel
if panelID == 0 {
var windowFrame = self.view.window.frame
let panelWidth = splitViewItem.viewController.view.frame.width
if splitViewItem.collapsed {
windowFrame.origin.x -= panelWidth
windowFrame.size.width += panelWidth
} else {
windowFrame.origin.x += panelWidth
windowFrame.size.width -= panelWidth
}
self.view.window.animator().setFrame(windowFrame, display: true)
}
splitViewItem.animator().collapsed = !splitViewItem.collapsed
}, completionHandler: nil)
}
}
I am aware of the "Don't cross the streams" issue (from session 213, WWDC'13) where a window resizing animation running on the main thread and a core animation collapse animation running on a separate thread interfere with each other. Putting the splitViewItem collapse animation onto the main thread seems like the wrong approach and I've got a nagging feeling there's a much better way of doing this that I'm missing.
Since I am not finding any documentation on the NSSplitViewItems anywhere (yet) I would appreciate any insights on this.
I have the little test project on GitHub here if anyone wants a look.
Update The project mentioned has now been updated with the solution.
Thanks,
Teo
The problem is similar to the "don't cross the streams" issue in that there are two drivers to the animation you've created: (1) the split view item (2) the window, and they're not in sync.
In the example from the '13 Cocoa Animations talk, constraints were setup to result in the correct within-window animation as only the window's frame was animated.
Something similar could be tried here -- only animating the window's frame and not the split view item, but since the item manages the constraints used to (un)collapse, the app can't control exactly how within-window content animates:
Instead the split view item animation could completely drive the animation and use NSWindow's -anchorAttributeForOrientation: to describe how the window's frame is affected.
if let splitViewItem = self.splitViewItems[panelID] as? NSSplitViewItem {
let window = self.view.window
if panelID == 0 {
// The Trailing edge of the window is "anchored", alternatively it could be the Right edge
window.setAnchorAttribute(.Trailing, forOrientation:.Horizontal)
}
splitViewItem.animator().collapsed = !splitViewItem.collapsed
}
For anyone using Objective C and targeting 10.11 El Capitan.
This did the trick for me, didn't need to set AnchorAttributes.
splitViewItem.collapsed = YES;
Followed a few tutorials and I'm having no luck, I'm trying to add a simple .WAV sound effect into XNA using free samples, I have named the sound as:
SoundEffect hit1;
SoundEffect hit2;
And then loaded the content with:
hit1= content.load<SoundEffect>("hit1")
But when it comes to adding the play to a button press and I go to test it there's no sound at all even no errors or nothing the game loads and is playable but any sound effects are not working.
** // Sounds
SoundEffect hit1;
SoundEffect hit2;
This is my variable names:
// Sounds
hit1 = Content.Load<SoundEffect>("hit1");
hit2 = Content.Load<SoundEffect>("hit2");
This is how I'm loading them in the loadcontent method:
//If Keyboard Key W is Pressed or Buttong Y
if (keys1.IsKeyDown(Keys.W) && oldKeys1.IsKeyUp(Keys.W)
|| (oldpad1.Buttons.Y == ButtonState.Released) && (pad1.Buttons.Y == ButtonState.Pressed))
{
secondsPassed = 0;
// IF The Target Image is a Gnome
if (targets[0] == sprites[0])
{
//They whacked a gnome
GnomeHits = GnomeHits + 1;
runNum = 0;
secondsPassed = 0;
hit1.Play();
}
else
{
//They whacked a troll
scoreNum = scoreNum + 1;
runNum = runNum + 1;
GnomeHits = 0;
secondsPassed = 0;
hit2.Play();
}
SetUpSpriteLoop();
And this is one of the control buttons I'm trying to assign sound too
when I hit F5 and run the game when I hit the key or button no sound at all.
I had a similar problem with Monogame (built from XNA's ashes) on a Windows 10 machine. I fixed it by reinstalling DirectX, and everything just worked.
My first recommendation would be to make sure you are updating the keyboard presses. I only say that as I can't see you doing that in your code. If you do not do this then the key states will not update and therefore you will never enter the if statement.
Once you have ensured you are entering the if statement, I would play around with the volume of the sound effect to make sure it is actually audible. I may be a bit off base there however if I am I suggest following this tutorial rbwhitaker is a great resource for XNA.
I am working in android. i wanted to cleara layout each time i press a button and start everything again(as in doing "Reset") . Its not working with the following code.
final TableLayout rel=(TableLayout)findViewById(R.id.tab1);
int k=rel.getChildCount();
System.out.print("k is"+k);
for(int x=0;x<k; x++)
{
View v1 = rel.getChildAt(x);
rel.removeView(v1);
}
So i tried to print the value of k and i got it like 0101100 where i expected an integer. Any help is appreciated ..Thank you
rel.removeAllViews(); helped me
Why not make it invisible
v1.setVisibility(int)