Android Custom Layout have trouble in layout xml file with design mode - java

I extend ConstraintLayout class for special purpose.
and I use this class in layout xml file.
not problem show layout.xml with text mode.
but try show layout.xml with Design mode,
android studio show me this message.
I already try 'Refresh', 'rebuild', 'clean build'.
but still show 'Missing classes'.
how can I fix this problem?

The problem is that you are referencing to a class that doesn't exist or is not where you are referencing to.
You can either fix the path by
Copying the class to the correct folder.
Fixing the path by clicking on Fix build path
Or, click on Create Class and copy everything you had in previous class into the new one.
I think the 3rd option will be the easiest for you.

Related

Can't add CircularSeekBar to my project

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!

New to Android development- what does this line of XML mean?

I am new to programming and trying to learn android development with android studio. I updated Java and tried to update android SDK when it crashed. I finally got the Android SDK update fixed but now I have this error in an app I was working on. It's in the activity_main.xml file
The error says "cannot resolve this symbol: MainActivity.java"
Here's the line where the error shows up.
tools:context="com.example.android.justjava.MainActivity.java"
MainActivity.java is red. I feel like it's directory tree issue, but I can't tell what the program wants so I can fix it.
Remove .java at the end, and make sure that MainActivity.java exists inside the package com.example.android.justjava.
What is the purpose of writing that line?
tools:context
This attribute is typically set on the root element in a layout XML
file, and records which activity the layout is associated with (at
designtime, since obviously a layout can be used by more than one
layout). This will for example be used by the layout editor to guess a
default theme, since themes are defined in the Manifest and are
associated with activities, not layouts.
Source: http://tools.android.com/tech-docs/tools-attributes

Where to place SlidingTabLayout.java and SlidingTabStrip.java files in project?

I'm very new to Android studio and I'm currently following a tutorial that implements a sliding tab layout for an application. The tutorial says to put
SlidingTabLayout.java and SlidingTabStrip.java in our project, but doesn't say exactly where. For now, I just put declared them as two classes and put them under the java folder. (...app\src\androidTest\java). However, when I try to include a SlidingTabLayout object in my xml file, it says "The following classes could not be: found:com.android4devs.slidingtab.SlidingTabLayout", which means I must have put those two files in the wrong place. Anybody used these files before and know where to put them?
Thank you
The error says could not found the SlidingTabLayout class. Which means you have to tell correctly where the SlidingTabLayout file placed.
in xml change com.android4devs.slidingtab to your package name. You can find your package name in SlidingTabLayout.java or in manifest file.

Using R.Java in Titanium module

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

Missing id class in R.java

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.

Categories

Resources