Home » Android » the android studio instantly remove my copy & paste import statement

the android studio instantly remove my copy & paste import statement

Posted by: admin June 15, 2020 Leave a comment

Questions:

i’ve a project (blank activity) set up by android studio 0.8x, but when i paste (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;

the android studio will automatically rollback (ctrl + z) and only default import statement will stay, so i can’t use any custom import statement now, what the matter is going on?

How to&Answers:

You can control the behaviour in Settings, Editor, Auto-Import. It is the “optimize imports on the fly” setting

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

Answer:

when you import any file and immediate remove just follow below step in android studio and change this setting …

  1. press shift key two times continuously it will open search everywhere box
  2. Type Auto import in this box. and result show auto import,click on this.
  3. There is one option Optimize imports on the fly under the name JAVA,in your case it is checked..unchecked it and your problem will be solved.