hello guys I need your help I need to save progress data in my app . I created an App for letter tracing and I want to save the progress of the which letter is done tracing . like the color of image will be change if the letter is done tracing. or it will have star and when the app is close I want the progress is still there and not to start all over again. please help me guys this the screenshots of my app.
When user swipes the finger on the screen you get (x,y) points of the touch events, so you can save the array of the (x,y) points the moment the user lifts his finger of the screen. As there may be a lot of points to save, you can decrease data by saving every second or third point in the array. Doing so will decrease the data you will work with but it also decrease the precision of the user line.
Related
I want to create an interactive graphic for my app. It will essentially be a simple picture of a bus line where users can select 2 stops at a time (one for departure times and another for arrivals) I'm not sure how to create this image though, and have it have 20 or so different clickable points. Is there a framework I could use for this? Or is there a way to do this in pure android?
Thanks for the help.
I would suggest writing an onClick listener and using a collection of Rect instances to manage the collision/position of the 'click'. Check out the on click page and the rect page.
One thing to keep in mind are the origin point of your clicks, I'd assume you'll want to use one corner of your image as the point (0,0) and reference everything (clicks and rects) from there.
I would say try to create an ImageView to load your image and set a touch event listener or a click listener to that view. Hard code all places that you want your image to react upon a click.
Check click using an event listener would require you to handle both ACTION_DOWN and ACTION_UP in the MotionEvent object passed in. But it's easier to grab the coordinate of where the user clicks on the page, so you only need one listener but needs to put more work on handling the conversion from the coordinate passed in by MotionEvent to the coordinate on image. This is particular a major issue when your image can be sized larger than the screen size.
Using a click listener would save you from this trouble. As #smitec said, you need to overlay rectangles on your image as "buttons", so you can react to user input based on which buttons they pressed. This way you need to bind listeners to all of them (I suppose) and hard code their positions on your image. But, as mentioned earlier, it saves you from dealing with coordinates later on.
My WebView loads a web page and this web page contains some images. Are there any ways to get coordinates of these images on screen when they is clicked ?
I need the coordinates of these images because I want to play some animations when people click on them but now i'm totally stuck with getting image's location :(.
Any helps will be appreciated. Thanks so much!
Since the website is also yours, you can use a javascript bridge to determine when an image was clicked, and in combination with dispatchTouchEvent you can get the exact tap location on the screen. The steps that you could take are:
monitor all tap events on the screen in the dispatchTouchEvent method of your activity
save the last touch on the screen
monitor image clicks using your javascript interface
when an image is clicked, use the last saved tap location you got in dispatchTouchEvent
When a user drags the image on the screen, I want to save the coordinates he dragged to a file, so that I can "playback" the movements.
If user moves a ball from top to bottom of the screen, I want to save that to a file, then on demand, read the coordinates and show the ball moving by it self, like recording the movement.
I hope this is clearer.
Thanks
What do you mean by "save"? Do you mean just retain the X,Y co-ordinates in memory as long as the Activity is alive, or do you need to persistently store the data for future use? If you need to store those co-ordinates persistently, use SQLite.
Edit: Just noticed you've said 'to a file' in the title, so yes, SQLite is the best option. Or, do you have a specific need for the data to be written to a file, as opposed to SQLite?
Your question is far too vague.
i just need to create an edit box with keyboard below..Below keyboard,,there should be an Slide finger on the keyboard link area while looking at the keyboard.As the finger slides, the key corresponding to the location of the finger on the keyboard link area is highlighted.And when i click on dragger,the corresponding letter should be printed on edittext.How could i do this.?.Thanks..
As I have figured out, you need to have a mechanism where you let the users draw letters on a surface, and then you put them in the EditText by detecting what it latter was.
As a concept, you can do this:
Below the EditText, have a Canvas area, where people can draw letters.
Since I haven't tried many of Canvas things myself, you'll have to do the R&D, sorry.
but listen for press and move events.
record each pixel where the user is moving their fingers, and when the user lifts the finger up, perform detection.
For detection, you will have to have a database which tells you which drawing pattern corresponds to which letter. For this, develop a base where you store which pixel traversal path refers to which letter, and allow a threshold level. then put this info in the database.
when the user finishes drawing, and you have collected all the pixels user had traversed on, compare the set with the database to recognise which letter it was.
I know it might become complex, and requires you to evolve your own data structures (sadly, i don't have any structure in mind for this purpose as of now) for this, but it will be extremely interesting, and time taking too! ;-)
Just disable the keyboard for EditText when you're about to implement it.
I am relatively new to Android. I am working on an application wherein
i want to display digital signals. But the problem is once I occupy
the available screen width how to i add a scrolling feature to
continue viewing the signal. Also i am drawing the signal using using
drawLine(), so what co-ordinates should i set for drawing the lines
when scrolling is enabled? Can somebody please give a simple example
where a line extends more than the available screen width and you can
scroll through to see the remaining line.
Thanx in advance.
I've written a few of these before in other languages, so I can ive you the principles, rather than an example. I'm assuming you have some sort of buttons to the left and right that allows the user to scroll through the data, and that your signal data is stored in an array. You will be able to determine how much data you can fit into one screen width based on whatever scaling factor you are using. Say your screen can display ten values at a time, then you simple store the starting point in your signal array and use that as the left most point to display on your screen. Then all you have to do is show the next ten values in your array. When the user selects the button to move left or right through the data simply increment or decrement the starting point. If you are streaming in your signal, then the stream can increment the starting point whenever you receive a new piece of data. A redraw after each start value change will give the impression of scrolling. Watch out for start and end conditions (i.e. you don't want to scroll until you have at least a full screen of data). All you are doing is creating a window onto the data you have.
Hope this helps.