I mean as a slider, like so:
Image img[]=new Image{"a.png","b.png","c.png"};
for(int i=0;i<img.length;i++){
limg = (new CustomLabel(img[i]));
cnti.addComponent(limg);
addComponent(cnti);
}
Sorry, I hope you all getting my question.
You can place a Label then replace it using Container.replace() while using a slide transition.
If you want to allow the user to swipe then you can theoretically you can use a a horizontal list but there were some bugs there in LWUIT.
There are more powerful options in Codename One including ImageView.
Related
I am very new to Android programming, but would like to change the style of my Switch View element so that it looks similar to the one that is displayed on the Android website:
and not like the one that I currently have:
I assume that because this is on the Android website it would not be difficult to change to this Switch style, but as I am new to Android development, I don't even have the faintest idea how to change this, and a large amount of time spent searching for the answer has not turned anything up as to what is causing my style to differ from the one on the website. Any help is welcome, thank you!
That's actually different enough that its going to be a pain- particularly the text on top of the switch instead of to the side. But lets ignore that and assume you only want to get the rest of the look, that you don't want words (words on a switch are a bad idea anyway, the word for "on" might be 7 characters in some language).
You can set the thumb drawable in xml via android:thumb. You can set the drawable for the background with android:track. If you want the side of the long area of the thumb to change,(its on top in your drawing on "on" and the bottom on "off") you'd need to change the thumb drawable when the state changes. The tinting of the thumb/track are controlled by android:trackTint and android:thumbTint.
You can see the other switch-specific xml properties at https://developer.android.com/reference/android/widget/Switch.html
i have a couple of questions about activity's
i have a activity which i want to create some options for it. for eg. i want the user to be able to change the font size of text views.
i am a noob in java and eclipse. first i thought i can change the xml values via java but then i found out that i can't and they are read only.
so what is the best solution for creating options which are visual like changing colors and font sizes and picture through entire project?
for eg. i have 10 activities and inside each activity i have some text views. i want to change all of the font sizes. in xml you can create a dimen and all of the text views with android:fontSize:"#dimen/example will have the same size. but in java it takes more code and time.
what should i do ? couple of examples would be nice
thanks in advance
so what is the best solution for creating options which are visual
like changing colors and font sizes and picture through entire
project?
Have a look at the setTextSize() method of the TextView class. This will let you set the size of the text programatically.
setTextColor() will let you change the color.
setTypeFace() will let you change the font.
Having said that about TextView, it applies to all the subclasses of TextView like Button, EditText, etc.
i have a activity which i want to create some options for it.
I suggest you create a singleton instance that encapsulates all the information to change the visuals of your activities like text size, typeface, etc. This instance should then be shared among all of your Activitys.
couple of examples would be nice
No, an SSCCE would be nice. We need to see what you have tried. Code or you didn't do prior research.
Please have a look at the following image.
This is a text view which I need in my next android app. However, I really don't know how to implement this kind of textview. I only know how to put a normal rectangle style textview. So, how can I achieve this? If textview is not possible, what are other options?
The simplest thing to do is to create an image (a 9patch would be perfect) and put your text over it.
I did a little image for you. Give it a try:
https://docs.google.com/file/d/0B-Ax5zr61_Dvb2QwcmtWUml1Q2s/edit?usp=sharing
Otherwise you can use a Layout that will wrap your TextView (with the rectangle background) and the image of the little triangle below.
You can also try to "paint" it (using Canvas I guess), but seems overkilling to me.
Simple aim:
To have default buttons in the navigation bar of my ActionBar with the text centre aligned. I simply want to use the default, simple way of:
ActionBar.Tab myTab = Actionbar.newTab()
myTab.setText("my tab's text");
What's the problem
I cannot find any simple way to do this whatsoever. You can't access the views (as ActionBar.Tab.getCustomView() always returns null due to it being the default view). There is no method that I can see in ActionBar, ActionBar.Tab, etc to get the current view, get or modify LayoutParams (especially Gravity). A visualisation of the problem is below (one line seems to work right, but double lined navigation buttoms definitely seem left aligned):
Unideal solution
Am I right in negatively thinking that the only way to accomplish this is to use custom views for all of my tabs, somehow guess / attempt to copy the default formatting for the tabs (as I can't find anyway to access these views) and assume / hope that the default formatting / font / style of ActionBar.Tab's text does not change any time soon?
Surely there has to be a better way?
AFAIK, there's no way you can access the Views in ActionBar. Using custom layout seems the only solution. However, doesn't Android align the text to center automatically? It apparently does so in all my applications.
please download the follwing example. it will help you. i am sure i take help from this demo.
https://github.com/JakeWharton/ActionBarSherlock
I am trying to make an image Viewer like the one shown in the figure below:-
Before i can start i have following questions in mind :-
How would i check for the number of images in the target folder so that i can iterate and include all the images in my app.
Secondly,i am thiking to scale the images down to 75x75 .But what i can't think is that how will i slide the images as scrollbar is moved
To be specific,what is the appropriate container for those 75x75 images queue and how that queue is shifted to left or right?(I already know how to get current scrollbar value and add event listeners on it to respond)
To check the number of images in the target folder you can use the File class.
As for the container you might need to create the animation your self. There is no a container ready for doing so.
This site ( and book ) has some ideas about it. I don't know how out-dated it might be though
http://filthyrichclients.org/
Unless I am misunderstanding, making a scrolling list of images is quite simple.
First, create a JList with a datamodel that allows images.
A great example is shown here:
Java drag and drop images in a list
Second, add the JList to a JScrollPane.
The scaling aspect can be easily performed using Scalr:
http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/