How to auto import the necessary classes in Android Studio with shortcut?

Android StudioKeyboard Shortcuts

Android Studio Problem Overview


I've just switch to Android Studio 0.5.1, and the things going so slow here, because nothing works in the regular way...

How do I import the necessary classes with shortcut?

I mean like this ones?

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;

Android Studio Solutions


Solution 1 - Android Studio

Go to File -> Settings -> Editor -> Auto Import -> Java and make the below things:

Select Insert imports on paste value to All

Do tick mark on Add unambigious imports on the fly option and "Optimize imports on the fly*

Screenshot

Solution 2 - Android Studio

Go on the missing declaration with cursor and press alt+enter enter image description here

Solution 3 - Android Studio

Ctrl + Alt + O to optimize imports

Solution 4 - Android Studio

On my Mac Auto import option was not showing it was initially hidden

Android studio ->Preferences->editor->General->Auto Import

and then typed in searched field auto then auto import option appeared. And now auto import option is now always shown as default in Editor->General. hopefully this option will also help others. See attached screenshot screenshot

Solution 5 - Android Studio

To import classes on the fly :

On OSX press Alt(Option) + Enter.

Solution 6 - Android Studio

File -> Settings -> Keymap Change keymaps settings to your previous IDE to which you are familiar with

enter image description here

Solution 7 - Android Studio

You can also use Eclipse's keyboard shortcuts: just go on preferences > keymap and choose Eclipse from the drop-down menu. And all your Eclipse shortcuts will be used in here.

Solution 8 - Android Studio

On Windows with Android Studio 1.5.1 : File --> Settings --> Editor --> General --> Auto Import

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIlya LibinView Question on Stackoverflow
Solution 1 - Android StudioAjay SView Answer on Stackoverflow
Solution 2 - Android StudioPipoView Answer on Stackoverflow
Solution 3 - Android StudiotningView Answer on Stackoverflow
Solution 4 - Android StudioShujatAliView Answer on Stackoverflow
Solution 5 - Android StudiojkhoslaView Answer on Stackoverflow
Solution 6 - Android StudioDennis MPView Answer on Stackoverflow
Solution 7 - Android StudioLeebeedevView Answer on Stackoverflow
Solution 8 - Android StudioDodiView Answer on Stackoverflow