Required:android.app.Fragment error - android

I am working on a simple application of tabs but when I do the return I throw this error I do not really know how to solve it, I read something about importing and you put "import android.app.Fragment;" But I already have it that way. I would appreciate if I can resolve my doubt to the point of this error thanks

As I cannot comment yet I will give a full answer altho you haven't provided full details I can guess your problem.
Answer:
You probably have different imports on your Fragment class and on your Activity as from your pic on your activity you import this:
import android.app.Fragment;
and on your fragment you probably import this:
import android.support.v4.app.Fragment;
meaning its not the same class therefore your ide yells that you have a class mismatch
you should import only one of these on both your activity and fragment..
gl!

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

custom imports?

I see people are doing like this:
import com.inducesmile.androidlocationtracking.database.DatabaseQuery;
and regards that import, this variable
private DatabaseQuery mQuery;
turns red.
it's different from something familiar like this:
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
can someone explain what it is:
com.inducesmile.androidlocationtracking.database.DatabaseQuery
and how do we fix it,
or how do we change it to our own website?
basically, I don't understand how to fix that error. thank you very much.
So, it turns out. it has a class name DatabaseQuery
and the com.inducesmile.androidlocationtracking.database is the package hierarcy, so, just follow the rule, you're good to go

why I cant see my layout file in eclipse

I have created a class which extends ArrayAdapter class. But while doint
View v = inflater.inflate(R.layout.xxxx,..) I cannot see my layout file. I dont know what does that mean. In other activity I can see it very well using R.layout.xxx.!
There is a simple solution for this issue.
Suppose your package name is
com.xyz.package
Now If you will look at the top of your code
you would find
import android.R;
replace this with
import com.xyz.package.R;
after replacing above import if you find still error that means your layout.xml file in res directory has errors. rectify it, clean and build it in eclipse.

I want import android.provider.Calendar;

i want import
import android.provider.Calendar;
how can i import this class in my application
I believe this is still not part of the public SDK.
You can still read the data though, I wrote an article about it: http://jimblackler.net/blog/?p=151
The class isn't public.
See http://groups.google.com/group/android-developers/browse_thread/thread/ae95c372af20f39e?pli=1
you can use the GIT file,it's free from google.in the git you will find all the classes of calender for android.

Categories

Resources