I have two files,
AzimuthAct.kt and Mathf.kt, all of my custom functions are in Mathf.kt.
how do you import all function to another .kt file?
something like:
import com.company.appname.Mathf.* // <-- doesnt work
import kotlin.math.* // work
this what i mean
Top level functions are members of the package declared at the top of their containing file
In order to use them outside their own package, you can import them individually as import kotlin.math.sin or if you want to import them all then you can use star import after package name as import kotlin.math.*
In your case if you want to import all the top level functions declared in Mathf file then you need to use a star import on package as
import com.company.appname.*
Now you should be able to access all your top level functions from Mathf.kt
Related
I'm working on a flutter project and I want to import a dart file in my main file but I don't know how to do it.
I import my dart file first import 'package:splash/Categories.dart';
and I initialized it like that final Category _category = Category();
but I have this error Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports
Please how can I fix it. Thank you in advance
This happens when the same class is in two different files. So if you want to use a specific class in specific file we need to use aliases.
Example:
import 'package:splash/Categories.dart';
import 'package:something/Something.dart' as name;
Use classname in Something.dart as name.class_name
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.
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.
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
When I type ImageView or AnimationDrawable I get a string of errors proclaiming:
AnimationDrawable cannot be resolved to a type.
line 14 Java Problem
I don't understand, do I need to create another class? Or do the AnimationDrawables just not go in the filename.java?
And if I do need to create another class, can you show me how?
Are you importing those clases?
// this must be placed at beginning of your file
// after the 'package' statemen
import android.widget.ImageView;
import android.graphics.drawable.AnimationDrawable;
If you are using Eclipse, you don't need to manually import those classes: you can press Ctrl+Shift+i and it will automatically add the imports statements that you need (it will also remove the ones that you are not using).
yes you need to declare the view that you are using
like, for imageview
import android.widget.ImageView
likewise for textview,
import android.widget.TextView