I am making an android app for a reservation system for an office. I want it so that users can click on a seat to reserve it. Also I want the seats to be color coded once they are reserved. I only have a picture of the floor map to work with. How can I do that using an image and buttons?
I'm adding this as an answer, as it seems this is really the right way to go.
Set up a relative layout. You don't need an actual graphic of the floor plan. That would complicate things in terms of screen sizes. You will almost certainly have to allow for landscape/portrait either way.
You can use imageViews and create a grid of your entire layout. Tag each of the images in the layout as row,column, like: 01, 02, 03, 11, 12, 13, etc, and indefinitely. This way you'll know which image was clicked on. Use, by default, the "available" state for each seat. Create a secondary "unavailable" version of the graphic that you can swap in later.
When a user clicks on an image, use an onClick handler from the XML to call a function that checks the seat. If it's available, run the steps to make it unavailable, and whatever other data you need to set. If it's unavailable, do nothing.
I wrote a BubbleWrap popping game a few months ago that uses this exact sort of model, and it works great. (i'd link it up here, but I do believe that remote linking/plugging is frowned upon here)
This whole answer is very much on the surface, as it is going to require research on the particulars. But this should be enough to get you moving.
A very easy implementatin would be, use relative layout, or if possible use gridlayout and arrange the buttons as the floor seats with numbers. when a button is clicked, reserve the seat, update some database or whatever to store information, and make that button disabled.
Related
I need to create the markups on image view that should look like the markings Instagram. The client should click on some position on the image, enter some text and save it.
For now, the only solution that I see is :
Get click position in the onToch event.
Dynamically put some edit boxes to this position.
Save the text and coordinates.
However, I don't know yet how this will work on different screen sizes.
Since I'm mostly web developer and definitely don't now all android capabilities I hope someone with experience will give me advice. Maybe there some widgets for this task, or algorithm for counting position?
I want to create dynamic treeview. But the levels of tree unknown. it's up to database.
So expandable listview not work for me,
is there any treeview example like below type in android ?
A...
->b...
->b...
->b...
->c..
A..
->b..
->c..
->d..
->d..
ExpandableListView is for sure something to look into, but may not expose enough functionality though.
Having said that: on a mobile device it may not be a good idea to show an arbitrarily deep tree, as the user a) may have issues selecting the nodes and b) may loose himself in navigation due to the reduced screen estate.
Especially for a) keep in mind that a touch point is not a few pixels like when you click with a mouse, but depending on screen resolution an area of 20x20-80x80 pixels.
I am in the process of writing my first android app. I figured, for a simple exercise, I'd write an app to keep score in bowling.
I want to create a picture of the pins, with a touch toggling a pin between standing, and fallen. Then an ok button, that completes the shot. After each shot is entered, have a picture of the score updated.
Then, I want to be able to click on a frame, and edit it...mistakes happen.
This seemed simple enough. At least if I were to whip up something in HTML5 I would be done by now.
However, I'm struggling with just drawing the UI...ugh.
Would I just create the pins as image buttons? And how do I align them properly...I can't seem to drag stuff where I want, it's all left aligned and stacked. Nothing like it should look.
And how can I dynamically create images for buttons? At least that's how I was thinking I would do the score (showing all 10 frames with the shots and running score.
I realize this is a beginner question. But I've been at it for five hours, and I'm no farther along.
I don't think it's necessarily fair to compare your speed in a dev environment you are new to with one you already know - you are bound to be slower in the new one.
To get more familiar with android's XML layouts, I recommend you take a look through some of the tutorials on layouts - on linearlayout, gridlayout, relativelayout, etc which I think will have you quickly working in XML to generate your ui.
One such tutorial is http://slodge.blogspot.co.uk/2013/01/an-mono-for-android-wrappanelflowlayout.html
Once you've learnt a bit about the XML, I suspect you'll also find the designer easier too.
For the questions about the pins, well these sound a lot like checkboxes, only drawn differently - so check out:
Custom checkbox image android
http://vimaltuts.com/android-tutorial-for-beginners/android-custom-checkbox
I'm making a simple whack-a-mole game as my first mini-project for android. I'm not sure how to go about this. I know the basics of setting everything up and such but I'm not sure how to animate the moles and make it so that when the mole is in the up position it can be tapped and a point will be counted. I know I can do an image button and have a counter go up(counter++) but I need to be able to switch frames from the mole in the hole to the mole in the up position. Anyone have an idea as to how to do this? Thanks!
Android allows you to animate objects in a variety of ways. If you only need 2 images to switch, like a button with 'pushed' / 'not pushed' states, you can use a special type of Drawable called a selector (which allows you to specify different drawables for the various states of the target).
If you need more than two images, you may want to use the simple View animation that Android allows you to create using xml. For instance, you can create an xml animation that specifies an image to move/rotate/scale from one initial position to another, creating the in-between frames for you.
Android also has a newer, more complex and full-featured form of animation (which you probably don't need to go into).
Both of these animation systems are detailed at :
http://developer.android.com/guide/topics/graphics/animation.html
Otherwise you will need to create a series of images that you iterate through at a steady pace (which is the fundamental idea behind animation).
I've already made this before, I'll give you an overview, just check my post here: Simple Whack a Mole overview
What's the best way to implement functionality in Android where I have a large amount of text (let's say a book), and I display one page at a time. However, instead of displaying it all at once, and having the user scroll through it, I would want to create it like iBooks where each page is separate, and the user "flips" through it [although, I don't need a fancy flip. A simple slide, like Kindle for iOS, would do].
So how should I go about this? Is creating a customview necessary, or is there some way to do it without that?
Previously asked (I think): How to do page flip/turn/curl effect in android
Possibly answered: Implement page curl on android? with a project at http://code.google.com/p/android-page-curl/
If that doesn't do what you need, you will probably need a custom view, and you'll probably need to do some OpenGL work. The animation and page bending done (to simulate bending the corner of a page) is quite possible but would require some knowledge of the math, which appears to be described at the answer. Your mileage may vary.
EDIT: ah, see Android Left to Right slide animation