Android studio will instantly delete my copy and paste for import

I have a project (empty activity) created by android studio 0.8x, but when I insert (ctrl + v) some import statement, like the following

import android.app.Activity; import android.content.res.Resources; import android.graphics.drawable.TransitionDrawable; import android.os.Bundle; import android.widget.ImageView; 

android studio will automatically roll back (ctrl + z) and only the default import statement will remain, so I cannot use any custom import statement now, what happens?

+7
android android-studio
source share
2 answers

You can control the behavior in the settings, editor, auto-import.

"Import Optimization on the fly"

However, I would recommend starting writing your code, Android Studio will highlight classes that you have not yet imported, and then you can add the necessary imports by simply typing Alt + Enter

+15
source share

when importing any file and immediately deleting it, just follow below in android studio and change this parameter ...

  • press the shift key twice, the search will open everywhere .
  • In this field, enter Auto Import . and the result shows automatic import , click on it.
  • There is one option to Optimize imports on the fly under the name JAVA , in your case it is checked ... it checked it and your problem will be solved. li>
+2
source share

All Articles