1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to import the necessary components

Discussion in 'Android Development' started by robothito, Feb 13, 2016.

  1. robothito

    robothito Newbie
    Thread Starter

    Hello and thanks always for the help.

    Right now I am following a tutorial (om android programming)
    So for example, say I type something like this

    Code (Text):
    1. private Button mybutton;
    it can happen that the class "Button" is not imported so Android Studio marks it with red.
    the tutorial says that to correct this I can point there with my cursor and type ALT+ENTER

    well, I have a mac, so I tried basically Option +Enter...

    it works sometimes..... and sometimes it doesnt. (Once it gave me some new element (GoogleApiClient) added by google or something)

    Anyway. First question: How can you correct this so that the necessary import appears above in my code ?
    Code (Text):
    1. import android.widget.Button;
    Also Second Question and actually very basic and important one!

    How do you "undo" things on Android studio. I mean there seems to be a "normal" undo and redo button on the menu but they don't undo things on my code!!! They actually -for example if I am in the java code switch to the XML screen or something like that. I can never "undo" if I say deleted a whole function by accident ot things like that. Any help greatly appreciated

  2. robothito

    robothito Newbie
    Thread Starter

    I think I already solved the first question.

    Put your cursor in the word (for example Button) then type Option+ enter. the key being put the cursor in the word.

    But still puzzled by the second question: there is no undo in android studio! I have tried the undo button and it does not work
  3. Deleted User

    Deleted User Guest

    Ctrl-Z is undo.

Share This Page