how to Add a Button on the home screen in android? - android

I want to add a button on the home screen and want to code in the click event of that button.
I have an application which has an activate button,As soon as this activate button is clicked i want that a Button gets created on the home screen and i want to code some database queries in its click event.I have already created that application,Now i want to place the button on the home screen.How do i do that.
Thanks in Anticipation.

I don't think you can create a button on the Home Screen on-the-fly by coding. In my book, the only way to get a button on the Home Screen is if the user adds it as a widget.

If you are using xml layout for it add the button widget you needed and set it's visibility by android:visibility="gone",when you clicked the first button to activate the button to display,make it to visible by getting the id of the corresponding button
for eg: btn2.setVisibility(View.VISIBLE);

Related

How to make Image button Visible OUTSIDE the app?

I need the image button to be visible when the user opens another app, you know, i need it like the floating button that is visible to the user when the user opens any other app.
i have a switch button the controls if the image button is visible or not
Have a look at this question.
Essentially you need to use the SYSTEM_ALERT_WINDOW permission which allows you to draw over other apps, make a custom layout file which contains the button that you want to show and use the WindowManager to insert it into the view.

How to detect multiple tapping buttons

Actually my problem is I am making custom dial pad in android I pressed one button and I want to press one more button to get the value of that button I am getting first button value only. When I remove completely finger from first button that time only I am able to press second button

options menu does not come up after back button press android

I have an android application where I want to display a LinearLayout when user clicks on options button(I am setting the linear layout's visibility to visible in onCreateOptionsMenu) and make it invisilble when user clicks on back button.
This works fine when I press the option button and then the back button-the view comes up and then goes away respectively.
The problem is when I press the option button again, the linearlayout does not show even though the visibility is being set to visible.
However, log tells me that the methos onCreateOptionsMenu is entered.
Why would this happen?
onCreateOptionsMenu is called only once per activity. In your case you have to code in onPrepareOptionsMenu. This will be called every time the user presses menu key.
Why do you want do this? For android users relevant reaction for menu button is option menu.
What about question, try use View.bringToFront() - it will bring view in front of all views of the same parent.

Selected button during Home Screen

I have a home screen with a Home button. This screen is the default screen when my application starts up. I would like to show the Home button as selected to indicate that the user is in the Home screen when my app starts. How do I do that? Please help.
Thanks.
I think for what you want to do you want to either use a group of RadioButtons, or tabs. If you just want a button that looks different in different states, try using a StateSelector.

how would you disable a button till the user navigates through prior buttons?

how would you disable a button until a user click on the buttons prior to it. One of the buttons has there bio info which is set in preferences. So I can't have them continue until they read the directions and fill there bio.
Disable it in the layout file and only activate it in the activity (onCreate()/onResume()) when the needed info is filled in
In onClick() for the button you want to press first call setClickable(boolean) for the button you would like to activate.
Also, if you want the button to start as being unclickable you should set the clickable attribute in your xml to false as well
<Button
android:clickable="false"
Hope this answers your question!
Perhaps make a state button for this task? Or have a state object that controls the button

Categories

Resources