There are situations where you have to use a Canvas. What do you do if you have more text than you can properly display?
The problem is, that if you want multiline text on canvas, with the drawText method, you would have to measure how much space a single line of text would take up, and also compare it to the width of the screen, and draw each line separately.
Read more to check my solution.
As we previously desribed in PreferenceActivity Basics a preferences screen with basic features can be done with minimal work, only using XML. Now we will inplement some functionality beyond the base ones, this will require some coding in addition to the XML definition.
We will display the actual value in each preferences summary field, like this:
The base XML will be the same as in the previous example, but we dont need to fill summary fields, they will be filled dinamically.
Removing an application icon after installation programatically is a bit more tricky.
You can not disable the icon itself, but you can disable one component of an application. So disabling the applications launcher activity will result its icon to be removed from launcher.
The code to do this is simple:
ComponentName componentToDisable =