Method of dynamically switching component background for Android

The function of the program described in this paper is to dynamically select component background, system skin, custom toast background and so on. In order to achieve this requirement, you need to use the sharedprefence function in Android. First, write a control in the setting, set a click listener, and when you click, an alert selection pop-up window will be displayed for you to select. For this pop-up window, set a click listener (onitemlistener), and when you click to a specific point, Save the corresponding click ID to sahredguarantee, so that other places can get the value selected in the setting from here for dynamic personalization.

The specific codes are as follows:

1. Set the selected operation:

2. Display the operation of custom toast:

3. It is summarized as follows:

(1) Pay attention to the application of arrays. IDS [value] should be able to be used in this way. It is a good way and idea to write image resource files in an IDS array. (2) Be careful. When you get SP, the name is written incorrectly, and config is written as configs. (3) Understanding debugging skills depends on experience and logical reasoning.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>