I swear, this control has been the bane of my existance this week. Just FYI, I have pretty basic OO/Java skills, I've mainly been using xml to create layouts, but I need to use the gallery control. I've finally got the sample code working from the sdk, but one thing remains a mystery despite looking here, googling elsewhere, etc., there seems to be no clear answer on how you exactly manipulate the attributes of individual images within the gallery. I keep looking for an example of a template that I could implement, but see nothing. Really, I'm not looking for anything fancy, I just want the images to scale properly within a fixed height gallery control, and surround each image with a 1dip light border, and keep each of them about 4dip apart from one another, that's about it. But for the life of me I'm just not seeing how to make these customizations, and I'm starting to tear my hair out! :-/ Any help or reference to how to do this with some actual examples would be priceless!
Yeah, just to continue on your own answer.
The getView() method of the adapter is the place where you'll do anything you want with the images, i.e. set up borders, layout params, lazy loading, etc.
As long as the method returns the View you've made changes to, it should work just fine.
Related
I'm making a custom view that can be annotated with typical paint tools like draw, shape dropping, or writing text, and I'm stuck on how to enable text input without resorting to creating new views on touch. I'd like to be able to handle all of the annotation in this one custom view class.
My idea is to extend EditText, since it seems to have all of the functionality I need for creating editable text onscreen. Currently, I override onTouchEvent(MotionEvent event) to annotate whatever drawable has been loaded into my custom EditText called AnnotationView. I can call super.onTouchEvent(event) when the text tool is selected, and the soft keyboard displays. Entered text is displayed on screen, and I can edit it. However, at the moment I can only enter text in one place, seeing as how this currently is just an EditText with added drawing capabilities. Any other overridden methods (onSizeChanged, onDraw, performClick) start with a call to their super implementation.
Has anyone here attempted something like this before? I need to allow the user to start editing text at their touch coordinates, but I have no idea what methods I'd need to override or create to do that. It seems like this would be a good way to avoid requiring more views be created from the Activity using AnnotationView, but I'm not sure how feasible this approach really is.
Issue can be seen here:
Image of AnnotationView being used in a sample app
To explain why I'm trying to avoid creating new views to write text in - I'd like to release this as a library, so I'm trying to require the least amount of hassle for someone using this view. Ideally, a developer could just place this view and then choose whatever tools I've implemented via their own UI. If I need to create views on top of this, I'll need to require users to roll their own text editing implementation via some kind of listener... maybe? If I'm missing a simpler way of doing this, please let me know! I've seen similar questions asked here, but it seems like a definitive good practice for capturing user input and displaying it on canvas would be useful for a lot of beginners such as myself.
I was wondering if there was a way to make one component (in this case a JPanel) visible in more than one of the tabs.
I have a simple JFrame which is completely filled with a JTabbedPane. Each tab has a slightly different function, which is why they're in different tabs. However, they each output the same type of information. I was wondering if there was a way to make it so the same output panel could be seen in all the tabs, without having to create one panel for each tab.
I realize that it is impossible to add one component multiple times (and have it display independently each time), which is why I'm not optimistic about this being possible, however if it is, it would make my code much cleaner. In the case that this is not possible, I am completely open to alternate suggestions that achieve a similar result. I am in the very beginning of my project, so it won't be too difficult to change things.
This image gives a rough idea of what I'm trying to make it look like:
I have searched around for anyone dealing with this issue, however I have had little luck finding anything relevant. If I missed something, I apologize for wasting your time.
I would like to create a custom Android button from 9patches, but without using any XML. I know, it sounds dumb, but the reason is that for some reason my IDE (NetBeans) messes up the whole XML beyond belief. The R.java doesn't get generated half the time (the fixes didn't work for me), and I get random errors, even if I just copy and paste XML from tutorials.
This is how I plan to create the Button:
The button has a setBackgroundDrawable() method
I need to suply this method with a StateListDrawable
Which I need to build up from NinePatchDrawables
So first I need to create the 9patches, then a StateListDrawable from them, and simply pass the StateListDrawable as background for my Button's setBackgroundDrawable() method.
I can't start the 9patches, because I can't find out how the constructors work.
Wouldn't it make more sense for you to invest your time in either:
fixing NetBeans, or
switching to some different editor/IDE?
Trying to do Android development without XML is akin to trying to fly without wings. It's possible, but rockets tend to crash and burn in the end.
Regardless, you do not need to directly work with NinePatchDrawable to use nine-patch PNG files. Android will handle that part for you.
Instead, create an instance of StateListDrawable and call addState() for each one of your states. To get the Drawable for the state, use getResources().getDrawable(R.drawable.this_is_one_of_your_nine_patch_images) from your Activity. Android will detect that this is a nine-patch and will do the right thing.
I'd like to open a html-page in a webview and make it auto-scroll downwards automatically in accordance with an interval set through a timer.
Although below example is for desktop, this link should give you an idea what I want to achieve (enable autoscrolling in the upper right part of the page):
example
First I thought about opening a webpage and then use some kind of code which would simulate/trigger DPAD-down (or Arrow-down). In Windows Mobile, I believe there was something called SendKeys but I couldn't find something similar in the Android-SDK (except for a test-SDK which I doubt I could use for publishing my app in AndroidMarket) so I guess the way mentioned above is not possible.
Another solution could perhaps be a java-script but the webpages are not created by me so I can't insert any anchor.
However, I noted that Webview has some methods called PageDown (and PageUp) which could also be a solution but I am afraid a PageDown would be too much for scrolling the way I want. I want the scrolling to be slow and smooth, more like a line at a time.
Do you have any ideas how I could implement this? I'd really appreciate your help.
You could try using,
View.scrollBy(int x, int y) to scroll the WebView.Use:
computeVerticalScrollOffset(),
computeVerticalScrollExtent() computeVerticalScrollRange() to calculate a maximum y value.
i wonder how you can make an advanced Android User interface where you can add for example a drag drop and more graphics options? is that by using OpenGl ?!
this is example of UI in iPhone Apps.
example 1
example 2
Thanks
Your examples just seem to be composed of a lot of nice images. Your first example looks pretty static and could probably be made from buttons with custom images and setting lots of backgrounds on your layout items. The second looks like you would need to make a custom Gallery and do a little more manipulation and composition of images so it might be worth your time to go a little lower level for performance.
Basically, you're looking at using a lot of images. You can make them work with existing widgets and components and get the functionality more easily, or you can use OpenGL ect. To get some more flexibility and performance at the cost of having to code all the functionality in yourself.
If you're looking at drag and drop this post points to the source for a ListView with some rudimentary drag and drop functionality.