问题
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.
回答1:
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.
回答2:
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);
来源:https://stackoverflow.com/questions/4489274/how-to-add-a-button-on-the-home-screen-in-android