ArrayList<Integer> al = new ArrayList<Integer>( );into a string:
String output = ""; for(Integer n : al) { output += n + "\n"; }Perform this operation using a StringBuilder collection instead. If there are many items in the arraylist, using a StringBuilder collection is much faster.
HashMap<String, Integer> map = new HashMap<String, Integer>( );How do you add an Integer object to the collection using the key "K123"? How do you retrieve the Integer object? We will use a similar concept when we store information from an activity in a storedInstanceState object.
c java kotlin pythonThen use the ArrayList method replaceAll that accepts a lambda function to convert each of the strings to uppercase.
Switch ToggleButton ButtonWhen the button is clicked, show the states of the switch and the toggle button.
android:text="Greek letters: \u0BC1, \u0BC2, \u0BC3"
{"red", "orange", "yellow", "green", "blue", "indigo", "violet"}Add the Spinner items dynamically in the activity code. (Do you know about the acronym ROYGBIV for remembering the colors of the rainbow?) Also, after a color is selected and the linear layout is clicked, change the background color of an ImageView widget to the color selected in the spinner.
Event | Event Handler | Description | Required |
---|---|---|---|
ON_CREATE | onCreate | Fires immediately after the activity is first created. | Yes |
ON_START | onStart | Fires immediately after the activity becomes visible. It prepares the activity to move into the foreground and become interactive. | No |
ON_RESUME | onResume | Fires when the activity moves into the foreground after going into the background. | No |
ON_RESTART | onRestart | Fires when a covered activity moves into the foreground after being stopped, but not destroyed. | No |
ON_PAUSE | onPause | Fires immediately before the activity moves into the background. It may still be visible. | No |
ON_STOP | onStop | Fires when the activity has finished running and is no longer visible to the user, but may still be in memory. | No |
ON_DESTROY | onDestroy | Fires immediately before an app has terminated and is about to be unloaded from memory. | No |