Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I wanted to loop three images switching like this.
http://www.transum.org/software/SW/SnailRace/DiceAnimated.gif
int i=1;
while(i<5000){
enemyj.setImageResource(R.drawable.paper);
i++;
enemyj.setImageResource(R.drawable.rock);
i++;
enemyj.setImageResource(R.drawable.sciss);
i++;
}
the duration is there but there is no image showing. the image afterwards is showing fine
What you need is AnimationDrawable take a look at official page, or check it on google
You just need to use AnimationDrawable.
This is a blocking while loop - only the last setImageResource will be visible to the user.
I suggest you check out Frame Animations: http://developer.android.com/guide/topics/resources/animation-resource.html#Frame
Related
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 9 years ago.
Improve this question
suppose I want to design Java GUI frame with 30 radio box on it . Are there any way to add them without write many lines of code may about 60 line ?
for (int i=1; i <30; i++){
//radio check box adding code here
}
Declare all radio button names in an array and do the iteration like following,
String[5] radioString = {"P","Q","R","S","T"}; //declare as much as you want
for(String radioName : radioString){
JRadioButton rectangular = new JRadioButton(radioName);
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
How can I make the JSpinner go back to the last valid value when it loses focus and also when I press the spinner arrow button?
You could use an InputVerifier or adjust the spinner model to provide min/max values. See How to use Spinners
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to make a simple component that does nothing other than draw an arbitrary image, and then directly beneath it place a JLabel for displaying arbitrary text.
How can I achieve this? I'm brand new to Swing and I'm trying to learn as I go, but I don't currently understand how I would go about doing this. I know it's a basic question, and I appreciate any help I can get.
JLabel is your friend:
JLabel label = new JLabel("Your text here");
label.setHorizontalTextPosition(SwingConstants.CENTER);
label.setVerticalTextPosition(SwingConstants.BOTTOM);
label.setIcon(new ImageIcon(this.getClass().getResource("/path/to/image/image.jpg")));
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm building a surveying app. On the creation of survey activity, I am having trouble how to implement the number of options to a particular survey?
For example let's say I want to ask:
What is your favourite Programming language?
1. C++
2. Java
3. C#
4. Python
5. I hate programming!!
Then in the next survey, I want to ask a Yes or No question:
Do you like ice cream?
1. Yes
2. No
See, options vary depending on the survey question; therefore, I am thinking of first asking the user how many options they would like to have then show them. However, I am unsure of going about doing so.
Can anyone please help me? I'll greatly appreciate it.
You can add TextView dynamically with this code
TextView textView = new TextView(<context intance here>);
textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
textView.setText("Sample Text");
Then add created TextView instance to your view container:
viewContainer.addView(textView);
You can change your view's layouting by its LayoutParams.
if you have radio buttons to chose from your answers you can try to only show as many radio buttons as many answers you have with a if clause
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In my App I have a ListView, which is fed by a LinkedList.
Some of the Elements in the List are "kind of special". which is why I want to highlight them in some kind.
E.g. underline their names or have them differently colored.
Does anyone know how i can achieve somthing like that?
One thing that you could do is to make your own adapter by extending BaseAdapter.
Then, in getView(), you can check the contents of your LinkedList and based on that you can return an appropriate view with underlined text, different colors and so on.
here is a tutorial: http://www.javacodegeeks.com/2012/10/android-listview-example-with-image-and.html