button click counter blackberry cascades [closed] - blackberry-10

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm trying to make an app that count how many times you've clicked the button in blackberry 10
so i'm trying to int a value that will increase by 1 when you click the button
import bb.cascades 1.2
Page {
Container {
ImageButton {
defaultImageSource: "asset:///item_XS_6405840_3762396.jpg"
onClicked: {
count.setText(count + 1)
}
onTouch: {
count.setText(count + 1)
}
}
Label {
text: "you've clicked:"
}
Label {
id: count
text: 0
}
Button {
id: reset
text: "reset"
onClicked: {
count = 0;
}
}
}
}
I only have knowledge in java. thanks for helping

Related

Does anyone know what this stack is called SwfitUI? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 months ago.
Improve this question
I'll keep it quick: Does anyone know if SwiftUI have a built in method that renders something like this image:
where the view just changes based on what label you tap? I wonder if it's possible to achieve this using some sort of navigation view or stack? I'd appreciate any input! Thanks.
EDIT:
HStack {
Picker(selection: $selected, label: Text("Mode"), content:{
Text("Projects").tag(1)
Text("Notes").tag(2)
Text("Docus").tag(3)
}).pickerStyle(SegmentedPickerStyle())
.frame(width: 200, height: 10)
.padding(EdgeInsets(top: 0, leading: 0, bottom: 10, trailing: -0))
if selected == 1 {
// how would i show another view if the user selects option 1?
}
}
This is a picker. to be precise, this is a segmented picker.
You can create it like so:
struct ContentView: View {
#State private var favoriteColor = 0
var body: some View {
Picker("What is your favorite color?", selection: $favoriteColor) {
Text("Red").tag(0)
Text("Green").tag(1)
Text("Blue").tag(2)
}
.pickerStyle(.segmented)
}
}
When we create the picker we pass in a binding (when we change the picker's value it will know to switch to it) this is the thing with the dollar sign ($)
The next thing is to add the segments.
So we add text views with a tag attached to each one.
Lastly we need to set the picker style (in this case the segmented)
.pickerStyle(.segmented)
I suggest you to look here: Create a segmented control and read values from it
Hope this helps!

what's an efficient way in swift to get a "change of day" event [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
so I've a swift-ui app where I show information for the current day - so at midnight I want it to switch to a new day - trouble is I want this to be as "light" as possible - eg I don't want anything consuming any resources as all I want to do is refresh the view, if it's displayed.
How do I do this without consuming background resources when the view isn't shown?
you could try something like this:
(note I did not wait to see if this works)
import SwiftUI
import Combine
#if os(iOS)
import UIKit
#endif
#main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
var body: some View {
Text("day change")
.onReceive(NotificationCenter.default.publisher(
for: UIApplication.significantTimeChangeNotification)) { _ in
print("----> day time has changed <----\n")
print("A notification that posts when there is a significant change in time, \n for example, change to a new day (midnight), \n carrier time update, and change to or from daylight savings time.")
}
}
}

Flutter : Voice command to give user weather and date time update [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I want to create an application that work on voice command. In this application there is two options when user ask for weather or time update the application get the current weather and give update about weather in voice and the same functionality for time and date. Please help me how I can achieve this in flutter.
You can either use :
https://alan.app/docs/tutorials/flutter/integrating-flutter
or use:
https://pub.dev/packages/speech_to_text
import 'package:speech_to_text/speech_to_text.dart' as stt;
stt.SpeechToText speech = stt.SpeechToText();
bool available = await speech.initialize( onStatus: statusListener, onError: errorListener );
if ( available ) {
speech.listen( onResult: resultListener );
}
else {
print("The user has denied the use of speech recognition.");
}
// some time later...
speech.stop()
Then treat specific words as commands:
void resultListener(SpeechRecognitionResult result) {
++resultListened;
print('Result listener $resultListened');
setState(() {
lastWords = '${result.recognizedWords} - ${result.finalResult}';
});
}

How to get Recent Photo? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Currently i and doing on an Flutter Camera Project. May i know how can i get the recently photo to show on the container like Instagram stories left bottom?
var result = await PhotoManager.requestPermission();
if (result) {
// success
List<AssetPathEntity> list = await PhotoManager.getAssetPathList(type: RequestType.image);
final assetList = await list[0].getAssetListRange(start: 0, end: 1);
filename = await assetList[0].file;
setState(() {
});
} else {
// fail
/// if result is fail, you can call `PhotoManager.openSetting();` to open android/ios applicaton's setting to get permission
}
This works for me for getting the most recent image from the device as a thumbnail according to the plugin used from the website given by you.

Ionic testing - asynchronous look for a change in ionViewDidLoad [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have troubles trying to test the value of a variable that change inside the ionViewDidLoad method
welcomepage.ts
#Component({...})
export class WelcomePage {
test: number = 0;
constructor(){}
ionViewDidLoad(){
this.test = 1;
}
}
welcomepage.spec.ts
it('test should equal be equal to 1', () => {
fixture.detectChanges();
expect(component.test).toBe(1)
});
But this test is not succeeding. If I do the change inside the constructor function (this.test = 1) then it is working.
======== UPDATE ========
It seems that it is a problem with ionViewDidLoad function triggered by ionic, it is working as usual by running ionic but not in the test.
It appears that ionic life-cycle events (ionViewDidEnter, ionViewDidLoad, ...) are not called during testing, by calling it manually it works :
it('test should equal be equal to 1', () => {
component.ionViewDidLoad();
fixture.detectChanges();
expect(component.test).toBe(1)
});
But then how are we sure that ionic really call ionViewDidLoad ?
Your variable is not setting because you have done it in wrong way. Your variable name is test and you are setting value in variable type which is number. Please see the following snippet, hope it helps.
#Component({...})
export class WelcomePage {
test: number = 0;
constructor(){}
ionViewDidLoad(){
this.test = 1;
}
}