-
Notifications
You must be signed in to change notification settings - Fork 0
FirstApp
When you get to this screen, go over to the left and click on the thing that says "button"
Click and hold and drag it to anywhere on the screen, and release.
You should see something like this.
Now go over to the bottom right hand corner and scroll down until you see the text menu. Click on the space next to it and rename the button do anything you'd like. In this case, will rename it to potato.
Next, go to the left hand side, and find the ImageView widget. Drag and Drop it anywhere onto the screen.
Then go to the bottom right hand corner again, and search the "search" property. Then click on the button with the three dots on it. A screen will pop up. select the ic_launcher and click ok.
Next, click on the main activity tab and type in the follow two lines of code under the activity class.
private ImageView imageView;
private Button button;
Then click on the ImageView variable, and a blue screen will appear telling you to press Alt+Enter. Do the same for the Button variable.
You screen should look like this.
Next, copy down the following code and put it under the current line.
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (imageView.isShown() == true)
imageView.setVisibility(View.INVISIBLE);
else
imageView.setVisibility(View.VISIBLE);
}
});
Click the run button above, and a screen will pop up asking you which android device to use. Select the emulator and click ok.
Once the emulator is finished building, you are now ready to use your program. Clicking on the button will make the android logo disappear. Re-clicking it will make it appear again.