Android Studio prevent import statements wrapping - android

I used Android Studio wrapping feature to ensure code does not exceed 120 characters. This works fine for almost anything, but Android Studio keeps wrapping import statements which is ugly. I would instead prefer to say to Android Studio to never wrap import statements.
current:
import com.acme.projet.ui.very.long.package.name
.InstallationCoreFeatureActivity;
import com.acme.projet.ui.very.long.package.name
.InstallationSelectorActivity;
import com.acme.projet.ui.very.long.package
.InstallationOtherFeatureActivity;
wanted:
import com.acme.projet.ui.very.long.package.name.InstallationCoreFeatureActivity;
import com.acme.projet.ui.very.long.package.name.InstallationSelectorActivity;
import com.acme.projet.ui.very.long.package.InstallationOtherFeatureActivity;
Does anybody know if it's possible and if possible, how to achieve this?
Edit: To crazy reviewer/editer, the wrapping in the current code example is done on purpose.

Related

Question on importing two classes with the same name - android.graphics.Color

I currently have a imported color class from another Android Library:
import com.google.ar.sceneform.rendering.Color;
but I need to import another color class:
import android.graphics.Color;
but after typing this import, it gives me the error:
so I have to end up removing the second import and use it manually like this:
mBtnColor.setColorFilter(android.graphics.Color.parseColor(color));
is there a way I can import both classes? or maybe use the second import without typing android.graphics.Color?
Create two classes: one inherits the first Color and does nothing and is called AndroidGraphicsColor and the other one inherits the appropriate class and is called AndroidSceneFormRenderingColor. Then use them.

MainActivity not reading Subfolders Android Java

I created an application that uses the Room, ViewModel approach. I created subfolders to organize my code as shown in the photo:
How do I make my Main Activity recognize the code created in the subfolders? I tried invalidate caches/restart already and tried many times to rebuild the project.
There was an issue when I created my folders. I used New->Folder->Java Folder when the right process should be New->Package
You have to write an import statement for the classes to be recognized:
import com.example.laundry.data.ViewModel.CustomerViewModel
I think there are various ways to solve this problem.
Process 1.
For your Adapter import this
import com.example.laundry.adapter.CustomerListAdapter;
For your ViewModel import this
import com.example.laundry.data.ViewModel.CustomerViewModel;
Process 2
If you write down your adapter/model class name it will show some popup. From there you can select.
just like when I tried to import InfiniteScrollAdapter I got these options
Process 3
Please check if you have already import that adapter/model class with the different package names. Just delete that line and import again with alt+ enter

Android Studio - Auto Import won't work even after 'fixing' the problem

Straight forward -> The Auto import function won't work on my Android Studio.
Example: I declare a variable 'Button btn' and I get no option to auto import (ALT+Enter) the Button library.
I have tried by going to Settings->General->Auto Import and changed the settings to this:
Screen shot
It still ain't working. So I tried to Invalidate caches/restart, still not working.
I have been searching for help all day, without really finding any helpful solution.
Change the value of the option Insert imports on paste to Ask instead of All. It should normally ask you to import new librairies that you need to have.

Android Studio can't resolve new XML layout

I'm making customized contacts app, which one of it's features are to send SMS.
All was going good until I wanted to create my sixth XML layout which 'setContentView' couldn't resolve, even if I'm deleting the layout and auto-creating it by using Alt+Enter.
I've looked up for solutions in here.
It's not related to R.java.
I made all to make sure the layout name is not misspelled.
setContentView(R.layout.activity_sendsms);
The layout is 100% there but still I'm getting from Android Studio the error:
Cannot resolve symbol 'activity_sendsms'
the eror and the show it's in the right place
Do I need to import something which I'm not doing right? (all others .java file imports are pretty much the same)
The imports:
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;
Apparently restarting Android Studio did the trick.
Thanks all for answering.

How remove unnecessary import from package eclipse for android

How remove unnecessary import from package eclipse for android.
When i add some method after removing it the import statements not getting remove.
Is there a way to remove from entire application...
Instead of removing one by one.
You can use ctr + shift + o for removing unnecessary import of your class.
It is not just for removing but also used for importing the class that is not yet imported to your class.
The only way by which you import all defined packages that means
CTRL+SHIFT+O

Categories

Resources