Hey,
I've been trying for hours to add this to my project to make a fuel gauge.
I've been doing everything as it is shown in the instructions. But I happen to encounter some problems that I can't resolve.
I've pasted the .java file as instructed evidence but I get 2 problems here. First the "gradle" folder is highlighted in red and the .java file in question has a red J in its icon. I've tried to search how to solve those but nothing works for me.
I don't know if the next problem is because of the previous ones but when I try to add xmlns:app="http://schemas.android.com/apk/res/com.devadvance.circulartest"
in the parent view in xml file i get the error to use xmlns:app="http://schemas.android.com/apk/res-auto" to "automatically" search for the custom view but it doesn't work. So I can't import the .java in the activity(its like its not there") and I can't use it in the layout file.
Please help I've tried searching on SO but I could't find anything to work for me.
Beginner android dev here :)
Thanks in advance.
I have tried to use your given customseekbar in a basic hello world app. It works perfectly fine for me.
I see you've put the com/devadvance/circulerseekbar/circularseekbar.java in the src folder instead of main/java. So it should be in src/main/java/com/devadvance/circulerseekbar/circularseekbar.java.
Also I found out that you don't really need to add the namespace xmlns:app="http://schemas.android.com/apk/res/com.devadvance.circulartest instead the default namespace of xmlns:app="http://schemas.android.com/apk/res-auto in the xml file should be fine.
Finally, don't forget to add import com.myapplication.R; in the customseekbar class to use your resource class R in the customseekbar class.
Hope it helps, otherwise let me know!
Related
I've got a problem with Eclipse. I use the ADT to develop Android apps directly in Eclipse. But right after creating a new project, I got an error in my "MainActivity.java"-file.
I googled and everywhere its said that I have to import an ".R" class from my project folder, which didnt work for me. I also completetely redownloaded Eclipse+ADT in one package this morning.
The line which gives the error is the following:
setContentView(R.layout.main);
Without the "import com.example.myapp.R" statement I've got the same error. Cleaning and rebuilding also didnt have any effect.
Do you have any ideas?
Thanks!
Try to type R r; in your code. Hover your mouse over the 'R' and Eclipse will say "R cannot be resolved to a type". Click import R (com.example.myapp). If this doesn't work then check for the folder gen to say Generated Java Files. Also check to see if they have the classes inside.
R.layout.main refers to a layout XML file in your "res/layout" directory. This seems like the layout file you are trying to reference is named something else.
.
You just need to make sure that your referencing the correct layout in your onCreate method.
setContentView(R.layout.activity_main);
Post the main.xml. Make sure you import your application's R file and not android.R. Restart eclipse, do a clean up by going to your menu Project-> Clean , refresh and tell us if it is fixed.
I need to start an activity in my titanium module.Then I have to setContent of my Layout in my pure java code, But I cannot locate the layout file in Titanium module.
I used below code but i get error that file not found.
int id = TiRHelper.getApplicationResource("layout.activity_main");
If i put my layout files inside "platform/android/res" i get error,any idea to help me?
invalid resource directory name:
[ERROR] Error generating R.java from manifest
Regards
Might have nothing to do with it but I once ran across this problem and solved by putting the application id in the com.company.app format
If your XML's contain errors your generated file might not build try erasing most of their content and making sure id's and file names are not duplicated and no capitals and spaces are used. If it works you can start adding stuff.
(or)
You're importing invalid R class I Think,
import yourpackage.R class
for example
com.example.R
what actully happends that u import android.R class not yourpackages.R
I am trying to build my Android project in Eclipse and this error is popping up in my console:
W/ResourceType( 265): Unknown XML block: header type 0 in node at 413
This is causing my R.java to not generate. I have absolutely no idea what this means. It's not even telling me which file is causing the error. This is quite a large project with many XML files and I've looked through every single one and they all seem to be okay. Can anyone shed some light on this?
Any help would be greatly appreciated.
R.java includes all Ids, layouts.. If there is any problem like formating error in id name or any other error of layout. then R.java file will not be generated & your java class file will show you error. so first check your xml file
There might be the possibility that you have put your xml file in the wrong folder under res dir. Like if you are trying to access <wallpaper> tag in Android xml file you must put it in res/xml directory otherwise it will show error.
You can try following options::
close other projects.
clean your project.
check in the source files(java classes), if there import android.R.* is present , remove that.
check in your res folder, if it is showing error in any folders like drawable, layout, values.
5.correct if you get errors.
R.java is not coming because it is not getting id of any/more resource/resources.
this will solve your problem. thanks
Your error may come from incorrect line ending. You should check this Link. Hope this help.
I am developing an Android app using Phonegap and jQueryMobile, working in Eclipse. I want the app, with the user's permission, to auto-install a launcher icon on the user's "desktop". I've found the example LauncherShortcuts.java on Android Developers, and I am almost to the point of getting it to work. That's a big achievement, since I know extremely little of Java programming.
Almost.
This is the example code online:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/LauncherShortcuts.html
One string or thingy in the code refuses to cooperate. Line 83...
TextView intentInfo = (TextView) findViewById(R.id.txt_shortcut_intent);
...has this constant or variable in it called "R.id.txt_shortcut_intent", and Eclipse says it doesn't recognize the id part. If I follow its suggestion of adding a class 'id' in R., it tells me there is no field txt_shortcut_intent in 'R.id'. That doesn't surprise me.
I've been able to fix a few similar errors involving R.something_or_other. But not this one. My R.java only contains the classes attr,drawable,layout, and string.
What is going on here and most importantly, what should I do to get this thing up and running? The launcher icon is all that stands between here and actually launching the app (how ironic).
If you find any errors in the project. Sometimes id of R.java entries will be shifted to string folder or R.java.
For this choose
project → clean
file → close all
click on your project
See the entries in id of R.java your ids will be in this folder
An android app uses an xml to define the layout of all the elements you want to display. In this case, you're missing an element that displays text called TextView. You don't have the Textview 'txt_shortcut_intent' defined in the xml, probably.
Here's the xml you're looking for (just copy and paste it into your main.xml):
http://developer.android.com/resources/samples/ApiDemos/res/layout/launcher_shortcuts.html
The ADT Plugin in Eclipse can only rebuild the R class if there are no (Java) errors.
Therefore, fix all errors and check if your layout ressource has the correct id (txt_shortcut_intent).
It's worth a try to clean the project and restart Eclipse.
I have been having a lot of trouble because of an apparent bug in the latest java release, that has stopped me and many other people it seems, from referencing images. For example, the following code will not compile, even though this is the code given by many sites:
ImageView imageView = (ImageView) findViewById(R.id.myimageview);
imageView.setImageResource(R.drawable.myimage);
(or to a similar effect)
What I'm looking for is an alternate way to access an image from the file system, without using said "R.drawable.*".
2 possibilities:
Clean your project (Project>Clean). This will probably also fix your R.java file.
Check your imports! Possible that you've imported the R class. Had lots of trouble with that too.
If you're really looking for an alternative, look at Assets.
EDIT
If the above doesn't fix it, check your res folder (incl subfolders) for suspicious files, and delete them. like for example files that won't open, have no extension, or have errors in them.
Is that the error that you're getting when you compile the code that you've posted? I've never seen this error before. I would suggest doing a Project --> Clean and if that doesn't work delete the R file in the gen folder and then rebuild.
seen the same problem,make sure you have not imported the .R package,if so remove it from th list of imports,delete the R.java class ,clean then rebulid the project.