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

懵懂的女人 提交于 2019-12-25 04:37:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!