I am new to Blackberry devlopment and i have created 3 screens for the Blackberry application. Now my question is how to link these screens like if iam on 1st screen and if i click a button like submit it should go to the next screen like this it should go from 2nd screen to 3rd screens.
thanks
UiApplication.getUiApplication().pushScreen(yourNextScreen);
See the documentation on RIM website.
You add a listener (I have given code for the trackwheelClick listener below, but you can use others as well depending on if you want a keypress or touch etc.
I have written in the matter of implementing the event on the instantiated object itself, but you can also subclass ButtonField if you really want to.
ButtonField closeButton = new ButtonField("Close") {
public boolean trackwheelClick(int status, int time) {
UiApplication.getUiApplication().pushScreen(new NextScreen());
return true;
}
};
Related
Okay so I am making an android application, and I have a list of goals let's say to make it easy to explain. A goal consists of a string. This data will be coming from a database so in the future, the length of the list may be slightly longer or slightly shorter. Each goal is placed inside the text of a button.
I have made this loop to create the buttons at run time due to the changing length of the list depending on whats happened before and this all works perfectly, i can create the buttons and they are placed where i want etc. This is the code I used to do this.
for (int i = 0; i < goals.size(); i++){
buttons[i] = new Button(this.getContext());
buttons[i].setLayoutParams(params);
buttons[i].setPadding(0,150,0,150);
buttons[i].setGravity(Gravity.CENTER);
buttons[i].setText(goals.get(i));
buttons[i].setBackgroundResource(R.drawable.btn_back);
buttons[i].setTextSize(30);
buttons[i].setTransformationMethod(null);
linear.addView(buttons[i]);
}
Now my issue is I want the click of each button to do a slightly different thing - depending on the goal ie, the text of the button. I really am struggling with setting up the click event so that different buttons will do different things even tho i have created all of them dynamically.
I can give more detail into the setup I am in in the android studio, but I feel I've given enough insight into my issue.
I appreciate any help.
My best guess is that if you already know what the function of each button should be according to the text, couldn't you just take the text of the button and then use it in switch (or something else) to get specific functionality like:
buttons[i].setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View view){
//Put whatever is common between buttons outside of the switch
switch(((Button)view).getText().toString()){
//And then just assign a case for whatever functionality you need specifically for each goal
}
}
});
I am trying to implement a simple logic in my application where the user is shown a popup (after sometime of application launch). The popup simply shows a TextView with some info message. This message is refreshed every time the application is launched and a new message is shown.
The UI of the popup matches my application UI - here maybe just popup background images is needed. Also one close button (X) is shown at the top right corner of the popup - to close this popup.
Logic of Showing Message: I have a String array having some 100 strings stored in it. I randomly pick one string from this array and populate the popup TextView showing the message. Please suggest if there is any better approach than what I am doing already here. Also is it possible to logic that if one message is picked then the same message is not picked until the other messages are shown at least once?
Logic of Showing Popup: This is what I am not able to implement. I do not want to anchor the popup with any user Event or Button click. I simply wants to show the message after some time - say
Thread.sleep(3000);
Now I have tried to use PopupWindow for this using the below code.
PopupWindow infoPopup;
LinearLayout infoLayout;
TextView infoTextView;
Button infoButton;
infoTextView = new TextView(this);
infoTextView.setText("Testing Popup Text");
infoTextView.setPadding(10,10,10,10);
infoButton = new Button(this);
infoButton.setText("Close");
infoLayout = new LinearLayout(this);
infoLayout.setOrientation(LinearLayout.VERTICAL);
infoLayout.addView(infoTextView);
infoLayout.addView(infoButton);
infoPopup = new PopupWindow(infoLayout,LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
infoPopup.setContentView(infoLayout);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
infoPopup.showAtLocation((CoordinatorLayout)findViewById(R.id.main_content),Gravity.CENTER,100,100);
But this popup is showing error at the last line giving null pointer on my
(CoordinatorLayout)findViewById(R.id.main_content)
parameter.
The issue that I am getting are:
First of all, I am not sure if this is the right approach of showing a custom UI popup. I am aware of AlertDialog but not sure which is the best option to go in this case - Please suggest.
Why the CoordinatorLayout is showing null pointer?
How to implement the top right (X) button logic in this Popup ?
1. Yes there are so many options for showing a custom UI popup in Android. You might select one from PopupWindow, AlertDialog or Dialog Activity. You need to decide which suits you best.
If you need to customize your UI a lot and have to show a list or some complex GUI then I would suggest you launch an Activity with theme.Dialog. Just set the theme of the Activity to something like this android:theme="#android:style/Theme.Holo.Light.Dialog". There's a plenty of tutorials for implementing a dialog Activity.
PopupWindow is another tool to customize your custom pop up anywhere in the screen. If you're showing this popup always in the middle of the screen, then I would like to suggest not to use this. The AlertDialog should work fine.
AlertDialog has many variants and as far as I can assume your problem, this one suits you best. You can have a cross button too in the top-right corner of the dialog (You can set the icons anywhere, as you can provide a custom layout to an AlertDialog). Personally I use this library to provide a custom layout to my AlertDialog. You can have a look at this too.
2. The NullPointerException is simple. Your layout doesn't have any id named main_content. Post your logcat if this doesn't solve your problem. Post the layout too.
3. As I've told you earlier, I use the library to provide a custom layout to an AlertDialog and you can have a look at it too. So after implementing this library you can easily design your own layout with a cross button and implement the onClick functionalities easily.
Hope this helps.
Activity with theme Dialog.
This is not a good idea. It looks like a pop-up, but you can't click outside the pop-up to close it.
PopupWindow
It will stop the application. When the user finish clicking the pop-up, the application can work again.
AlertDialog
The best one, it will not stop the application and can be closed by clicking outside the dialog.
I have a home screen widget and I have some trouble with it. I update my widget on click on the widget. A service starts, sets a message in the widget (Loading...) and updates the widget. It works correctly but if I click several times on the widget, the widget keeps in memory that I have clicked several times and it updates it several times when the previous click was treated.
Here is a sketch to really understand how it works (because my english is not as good as I wish): http://hpics.li/f3bcbaa
Thank you in advance for your help. If you need some code to understand what I would like to have, just ask me.
What about something like that?
boolean updateIsRunning = false;
if (!updateIsRunning)
{
updateIsRunning = true;
//perform your update
updateIsRunning = false;
}
I'm new to JSF and primefaces, and I'm trying to implement a function to open a popup and create content in there and save it.
I have a storyboard must be able to contain several scenes.
I created the db to work this way:
So, a Project can have several Units. Each unit has 1 storyboard("Roteiros") and each storyboard can have several scenes ("Slides") associated.
I'm trying to understand how to create a function to add these slides for the scenes in the application I'm working on.
I have a managedbean called cadRoteiro, where I can set methods to use in this functionality.
Interface Issue:
I have a popup for storyboard information (a list of scenes). I'm trying to create a button there to add scenes. The user clicks on this button and opens a popup with a having two inputs (title, description). I'm having problems to create this button:
<p:commandButton id="addScene" value="#{msg.add}" style="float:right;"
actionListener="#{cadRoteiro.novoSlide()}"
oncomplete="dialogTarefa.show()"
update=":tabUnidadeSlideTarefa:dlgTarefa,
:tabUnidadeSlideTarefa:formCadastroTarefas">
</p:commandButton>
Could you help me to understand how should be this novoSlide() method?
public void novoSlide() {
this.slide = new Slide();
changingSlide = false;
disabledSlide = true;
}
Also, the button to add scene I mentioned above opens the popup, but the editor (whose content I want to be the description of a new scene) is coming disabled. (the solution posted here: Primefaces editor in a dialog doesn't works doesn't work for me (the problem must be before that).
I know it's a lot of information, but I'm new to this and I really need some help, basically for two things: understand how could I create a method to get values from interface posted there, and to understand why is not being updated when the second popup is being opened.
Managed Bean code (cadRoteiro): http://pastebin.com/sGBws74h
Popup where form is: http://pastebin.com/9A2ZZtt7
I'm very new to programming with Android, so I'm making a simple text RPG to practice developing for the platform. The player has access to a menu, which shows their items as a group of Radio Buttons. That way one can be selected to Equip/sell/etc. The game is handled in a completely different Activity. I want a random event that can happen in the Game activity to be able to add a new custom Radio button to the Inventory Activity page. On my Inventory Activity page, I've written a simple method:
public void addRadioButtons(){
RadioGroup items=(RadioGroup) findViewById(R.id.invItems);
RadioButton newItem = new RadioButton(this);
newItem.setText("New Rare Item");
newItem.setId(idCounter);
idCounter++;
items.addView(newItem);
}
When the random drop event is calculated in the Game Event, it just does a object.addRadioButtons() method call. This force closes every time, no matter what I try. I've also tried pre-formatting the button before adding it, also to no avail. Am I missing something?
It seems, that the reason in idCounter value. In Android view id must be calculated according to certain rules. Look at this post for more detals.