Android: Master detail project has errors right after creation - java

I have the android 4.1 and 4.0 SDK installed on my laptop. I've done plenty of projects just using a blank activity, but when I decided to try a "master detail flow" example from within Eclipse (create new Android project, select MasterDetailFlow) the other day it wouldn't even let me build. I have errors right off the bat. Surely this can't be right? Here are the errors:
(1)The method onItemSelected(String) of type ItemListActivity must override a superclass method ItemListActivity.java /Master Detail/src/com/example/master/detail line 39 Java Problem
(2)The method onItemSelected(String) of type new ItemListFragment.Callbacks(){} must override a superclass method ItemListFragment.java /Master Detail/src/com/example/master/detail line 27 Java Problem
I'd like to try and use the master detail forms so I can understand more advanced android layouts. Could anyone point me into a better direction with that as well? Thanks!

Ugh, that's a pain, but it's a pretty simple solution. The rules for when you should/shouldn't use #Override switched from Java 5 to Java 6, so depending on Eclipse's default JDK it'll sometimes yell at you when #Override isn't there but should be, or vice versa.
Set the compiler level in Eclipse to at least JDK 6 and the errors will magically disappear :)

Related

Android Studio problem: Unused Java instance variable marked as used

I am using Android Studio 3.2.1 Build #AI-181.5540.7.32.5056338 (linux version). Although this problem might also appear in Intellij Idea which I have not tested. The problem is whenever I name my instance variables by certain names (like place,time,date) they are instantly marked as used right when I declare them! Below is a screenshot of the problem:
Here I just opened the default Hello World project and typed some declarations. I have not touched anything in the project other than this. Imagine how much of a nightmare would be this kind of misinformation for big projects! Can anyone here solve this or suggest any workaround (other than changing names of those variables)? (And also if you feel to downvote then atleast comment first)

Is there a way to see all the references of a method in netbeans similar to the newer version of visual studio

I was using a fresh installed visual studio when i noticed you can now quickly see the reference above the methods. I was wondering if there is a similar way to do this in netbeans ? Because sometimes when i refactor my code i'm losing a lot of time searching where all the references are .
Place the cursor on any method / variable / etc. and press [left Alt]+[F7] or just right-click on it and select "Find usages".
Netbeans 11 not support "Find usages" for js code :(

Basic Android Project: alternating cannot be resolved or is not a field/R cannot be resolved into a variable errors

I am new to Android Development/Java Programming/Eclipse so please bear with me. I've been going through the Android Developer Training (developer.android.com/training) and the Hello Android book by Ed Burnette and keep running into a problem that is making it difficult to move forward. I'll do my best to describe it and am hoping that the community can help me resolve it.
I began seeing this issue with the Android Developer Training (around Adding the Action Bar -> Adding Action Buttons) and it became impossible to circumvent at Hello Android's 3.3 Creating Opening Screen when I tried adding the Sudoku buttons. The only change I made when going through Hello Android was adding the Android Development Toolkit (ADT) for Eclipse. I don't recall this being a required download going through the Android Developer Training page so I am wondering if its addition could have contributed to the problem.
The issue that I keep running into is that when I go to build the project, Eclipse keeps telling me:
action_settings cannot be resolved or is not a field
activity_sudoku cannot be resolved or is not a field
container cannot be resolved or is not a field
fragment_sudoku cannot be resolved or is not a field
sudoku cannot be resolved or is not a field
I've tried several fixes that I saw on in the forum including deleting the import.android.R from the sudoku.java file in my src folder but that brings up a bunch of errors that say R cannot be resolved into a variable. I've tried cleaning and rebuilding and restarting Eclipse, methods that occasionally worked before Hello Android and the plugin, but keep getting the same errors. I've also tried setting to Android 3.0 and higher thinking that might be an issue but there was no change. Occasionally I get another error regarding not being able to find the path for a container but I've been playing around with the IDE for 15 minutes and can't seem to get it to pop up again.
I could really use some help on this.
Hope to hear from you,
Yusif Nurizade
This solution may, first and foremost, demonastrate how green I am with Android programming but I believe I found the solution.
Initially following the Android Developer Tutorial, I downloaded the latest versions - 18, 19, 20, etc. When I was creating the project, however, I was specifying much early versions for compatibility; all the way down to 7 or 8. I looked into this because I remembered seeing a message from the IDE regarding the Action Bar and how some commands weren't supported on Version X.
I went back and downloaded all the versions down to 7 or 8 and set the compatibility accordingly. The example now works with minimal other changes. I realize that I may be overlooking something but this is the only major change I made and it seems to have done the trick.
Hopefully this will help other newbies!
Yusif Nurizade

Code is not compiling in Netbeans using JavaFx implementing Controllers passing parameters

I was working this afternoon in my project without problems. Before come home I did a commit to my svn to continues it in home, but now when I try to run it shows a code error that hadn't shown before. The Following code it's supposed to initiate new scene using controllers and passing parameters. Error:
Someone knows what is happening? If you say "The code is wrong" it's not possible cause I was using the exactily same code in my work.
Detail, in the afternoon i was using Mac OS and now I'm using Windows. And IDE is Netbeans in booth places
My problem was not about code, actually the code is right.
The problem ocurred because my Netbeans was pointing to a old version of JavaFX. The way to fix it was to uninstall everything about java from my computer and after reinstall with the newer versions of JDK, JavaFx and Netbeans.
Cast your loaders to their appropriate types. For the first cast it to the Login Controller and for the second cast it to the MainViewController.
NetBeans only see's an abstract Object being returned, even though what is actually being returned is a little more specific. I'm not sure why this happened when you moved from one platform to the next (I assume you have the same version and everything), but some compliers will catch this as an error and others will not. Technically there is no error, just questionable results.

Android import project errors

Hey everyone, I'm a beginner, so I'll try my best to explain this problem succinctly.
Basically, a friend of mine and I were playing around with the Android SDK, editing a simple RSS reader. We could launch it in the emulator and even install it on our real devices.
Fast forward a few days, I'm trying to import the exact same code that was working a few days earlier into Eclipse on my laptop.
I tried both importing and new project from existing source. Both return these new errors that we never had originally.
I got an error that involved the auto generated "R" file, but I have solved this. Now, I'm getting 3 errors that I have never had before -
The method onClick(View) of type new View.OnClickListener(){} must override a superclass method - displayed twice ( 2 different lines)
The method onTabChanged(String) of type new TabHost.OnTabChangeListener(){} must override a superclass method
My question is this - What would cause the these discrepancies between importing/running on my friends computer and mine?
Also, we are both using the latest version of Java/Eclipse
Thanks in advance for any insight.
Are you building using the Java 1.5 or 1.6 tools? 1.6 allows the #Override annotation on interface methods, 1.5 does not.

Categories