I am going to code a walkthrough tutorial for my app.
I wish the user will follow the step of the tutorial. So I want to force the user to click on a specific button but not other parts of the app.
My app has many UI components and some of them are added programmatically so disabling them one by one is not practical.
One immediate solution is that I make a transparent Activity to cover the original Activity.
But I don't know how should I detect the touch event through the overlay Activity to operate the original Activity.
Or are there any better way to make a walkthrough tutorial on android apps without much affects to the original code? Tutorial is an adhoc feature and I dont want these adhoc features to ruin my coding with a lot of if-statement on every Activity.
Thank you.
Activity won't work. Only the one at the top of the stack can process infos.
Simply add a semi-opaque view above the screen using a relativelayout
Then simply monitor the ontouch event of this view. If the touch is in the accepted zone of the tutorial, then let it bubble up to underneath control. If if is outside the accepted zone consume the event.
Button btn = new Button(getActivity());
btn.setText("Next");
// Adding button to bottom
lv.addFooterView(btn);
Related
I am following this tutorial on creating basic pin code screens: http://lomza.totem-soft.com/pin-input-view-in-android/
I'm just stucked because I don't know how I would call another activity after the Pin code screen has been shown. I'm thinking that there's a button but I don't know where in the code exactly I would be putting the listener.
I just started studying android development so I'm not really familiar with it. Any response would be appreciated.
#Senya is correct, the tutorial is pretty much basic stuff, there's no Button provided and you should add one yourself if you really want one.
However the whole point of a pin is quick access for the user so it is better if you don't provide a separate done button but just listen for the keys in onKey() method and verify the pin as correct, and you can launch your Activity if it is.
In the tutorial just an example of PIN View without extra logic. You can add Button to layout or set listener to EditText for EditorInfo.IME_ACTION_DONE if you want.
Update: in this case listener should be added to the last EditText.
I am developing an app and I would appreciate to get some input and your 2cents about this scenario:
I want to have 5 buttons in a circle and 1 button in the middle.
The buttons in the circle shall be able to be moved to the middle button and there are two scenarios:
if the button touches the middle button --> switch screen
if the button does not touch the middle button and you stop moving --> it should be moved back to the original place (gravity)
Is it optimal to solve this scenario with buttons or would you prefer any other item?
Thanks a lot!
Developing this will take a lot of time and effort. I don't know if this can be done using simple buttons or you need custom elements but I can help you get started. Try looking into the Facebook chat heads behaviour. I think the behavior of chat heads when removing them (with the X circle in middle bottom where you drag chat heads to remove) is similar to what you are trying to achieve.
Here is some useful information you can go through and maybe you find what you're looking for.
What APIs in Android is Facebook using to create Chat Heads?
https://github.com/henrychuangtw/Android-ChatHead
https://github.com/marshallino16/Demo-FloatingView
Note: I am still going through all the information in these links because it looks like it might be helpful for you. You also go through the links and we can further discuss in the comments and later edit the answer when we have a solution
I would like to create effects like lock/unlock screen of android. I have attached the screenshot here as well. In lock screen we have 2 buttons but in my case I am having 3 buttons and the middle button must be draggable.
The middle button can be drag to left/right.
I know I have to create custom view for this to work but I don't have any idea about how to drag button left/right with nice effect(animations) which normally any android phone have.
I need guidance on this, so can anyone suggest me how to approach for this.
Basically i wish to move/slide button left and right and based on that want to take some action.
I have tried making a lockscreen application myself and i almost made it, but here are the facts you will have to face at the end
You will not be able to disable home or menu button.
you will need user permission (not the one you get while installing the application, the menu pops up every time you press the home button unless the user decides to make your application default home screen, if that does happen you have successfully made a lock screen) if you decide to make a home screen application too.
the lock screen doesn't go very well with passwords
But if it helps, here's what i did:
You need to create a service that keeps a check on the screen being off and on.
if the screen is off, you do nothing. when the screen if ON you start the activity and wait for the user to do the thing you want the user to make him unlock the screen. and when he does that you finish() the activity.
While doing that you need to setup a method that can listen to check the incoming calls you can do that by extending PhoneStateListener and also disable the back button.
Good Luck and if you are able to make any further progress do let me know.
Maybe this project could help you GlowPadView. I've used it succesfully in one project. Hope it's what you're looking for.
my question is not only about onTouch events but about every method I can use to recognise a touch on certain areas of the screen.
Right now, I have a "background" image, which I use as layout that contains 2 "buttons": Start and Options as you can see here:
Ok, what I want to know is which is the best way to identify when are the user touching each button. By the way, should be nice also some info about how to deal with the different screen sizes.
Lots of thanks.
PD: seems I didnt explain it well. they are not "Android buttons" theirselves. The background is a whole image, where you can find 2 "buttons", but they are a part of the image. Thats because I need to know how to do this
I think you're missing some fundamentals, so I recommend to take a tutorial track.
As a direct answer to your question , you can see this page from the tutorial.
Why do you want to set the touchListener on whole screen and find the buttons?..You can simply set the OnClickListener or onTouchListener on both the buttons itself..
Please don't delete it because its a duplicate. I am an android developer with little experience. I have an app with 2 screens. The first has a bunch of options in a TableLayout each selected using a RadioButton.
What I want to do is, when I select one option and click a Button which appears below, the View should switch to the next screen showing some related data and when a Button is clicked I want it to come back to the same screen but then the rest of the options should be available to me so as to repeat the same process with another one of the options selected.
In short I want to be able to maintain the state of the first screen. I can't seem to be able to decide between using ViewSwitcher, ViewFlipper, or multiple Activities or using a single Activity which is what I am doing right now. But as my app gets bigger its very difficult to handle it. Please suggest the best way to do this. I am confused and desperately in need of help because my job depends on it. Thanks in advance
Use 2 activities. Launch the 2nd activity when the user clicks the button. When the user clicks the "back" button (or some other button you offer him) the 2nd activity finishes and the first activity (which was underneath it) is shown.
Note: You've not given us much information, so I can't guarantee that this is the best solution. From what you've said this is the solution I would recommend though. As they say in advertising "Your mileage may vary" ;-)