I can't import android.text.Editable - android-studio

I've just been to began android app with beginner books
That book use "android text Editable"
cause I tried to import text Editable but i can't it
Then I found:
Why used import statement is specified as "unused import statement" in Android Studio?
As above I removed "Optimize imports on the fly "
But don't disappear yet
Why I can't import android.text.Editable
Someone teach me, please.
just in case I use android studio latest version.

Related

Android Studio: import org.tensorflow.Operation does not seem to work

I am using the latest Android Studio to create an image recognition project. I am using a .pb file downloaded from Github.
I have added "implementation 'org.tensorflow:tensorflow-android:1.5.0'" in build.gradle file.
When I go to the java file, the following two import statements are "unused"
import org.tensorflow.Operation;
import org.tensorflow.contrib.android.TensorFlowInferenceInterface;
Could somebody help? I am new to TensorFlow. Thanks!
Please ignore this question. I misunderstood what "unused" means.
Usually you don't have to add your imports manually. Android Studio shows some variants for imports and adds it automatically.
If your imports are grey and you get "unused" that means you didn't use them in this class so you can simply delete them.
It happens sometimes when you decided to write all imports before you actually code anything using these classes.
If you leave this warning nothing bad will happen but you use more memory than you actually need.

Android Studio doesn't show import suggestion

After trying adding the GSON library with "compile 'com.google...' ",I get a situation that when I try to import modules the IDE suggest me nothing except static and *. So I have to type everything. How can I fix it? I created new projects and still get this problem.
We're in 21 century and using modern IDE Android Studio. Why do you want to import packages manually just like we import when writing code in simple Notepad or any other text editor?
Just type the name of class which you want to use in your code. And the IDE is smart enough to show the suggestions which relates to your typed keyword.
I get a situation that when i try to import modules the IDE suggest me nothing except static and *.
Yes, it's indeed. Here is my screenshot
How can I fix it?
Very simple. Just type class name whatever you want and select it from suggestions. Android Studio automatically imports it.
For example (as per your requirement) you want to import #SerializedName() annotation. Type #Ser and hit Ctrl + Space and see the magic.
Now the Android Studio showing me the suggestions which matches with keyword Ser and I'll select SerializedName (com.google.gson.annotations.SerializedName). That's it.
Hope it'll be helpful.

How to control when Imports are replaced by wildcard in Android Studio in Kotlin files

I noticed that for up to 4 imports from the same package, auto-import will simply append the import in the list:
import android.support.v7.widget.AppCompatImageButton
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.Toolbar
But adding a 5th import will make auto-import switch to a wildcard:
import android.support.v7.widget.*
Is there a way to keep auto-import on but tell it to not do that, or change the threshold? I don't mind having a long list of imports, it feels... familiar.
You can set this under the Kotlin "Code Style" section in Preferences:
The Android Kotlin Style Guide says:
Wildcard imports (of any type) are not allowed.
You can set your Android Studio preferences to remove all wildcard imports from Kotlin files.
Open Android Studio Preferences: Editor > Code Style > Kotlin
Select Use single name import for Top-level Symbols
Select Use single name import for Java Statics and Enum Members
Remove all packages from Packages to Use Import with by clicking the minus - symbol until it says Nothing to show

Android Studio auto importing wrong Context class

Android studio has been auto importing io.realm.internal.Context instead of android.content.Context and its getting very annoying. I have to highlight and manually type the import statement because Android Studio continues to auto import the wrong class. Is there any way to tell the IDE to not auto import certain packages? I never use the Realm context class, and whenever I reference Context for the first time it always erroneously imports that class.
It is possible to tell the IDE to not auto import certain packages. Please refer following steps:
In Android Studio go to
Settings>Editor>General>Auto Import
In the dialog box that opens, type the name of the class or a whole package to be excluded, and click OK.
Use new (Alt+Insert) and delete (Alt+Delete) to manage the list of classes and packages that IntelliJ IDEA shouldn't place to the suggestion list.
Apply changes and close Settings/Preferences dialog.
This will surely help :-)

How to import .XML code style into Android Studio 1.5.1 for OSX

I am trying to import official Google code styles into Android Studio 1.5.1.
I have placed the file named intellij-java-google-style.xml here:
/Users/me/Library/Preferences/IdeaIC14/codestyles
As described by this answer on Stack. However, it does not appear:
I further attempted the approach described here and placed the same file in ~/Library/Preferences/AndroidStudioBeta/codestyles, but that also did not work.
Can anyone suggest the right way to import codestyles in Android Studio 1.5.1? Here is exactly what I am running:
You've placed the code style .xml in a path used by IntelliJ IDEA, not Android Studio. The corresponding path for Android Studio is:
/Users/me/Library/Preferences/AndroidStudio1.5/codestyles

Resources