No preview of custom views on UI designer in Eclipse
Asked Answered
T

2

3

Background

I've been creating many types of custom views, and normally i get their previews shown just fine on the UI designer of ADT.

lately, after updating to the newest version of the ADT ( 22.0.5.v201307292155--757759 ), i can't see any type of custom view, not even the simplest one .

The problem

now, i know for sure that custom views can be previewed fine , since if i create a new workspace and create them, i can see them just fine.

the problem is that on the current workspace, which has many settings for its projects, i keep getting this error:

The following classes could not be found: - ... (Change to ... , Fix Build Path, Edit XML, Create Class)

where "..." is the class of the custom view.

i also get a gray rectangle for each custom view i use, and Lint also complains:

Class referenced in the layout file, ..., was not found in the project or the libraries

this is very weird, since i used the correct syntax for the custom views in the XML (and i've done it a lot). even drag&drop didn't help.

it's also weird because eclipse can find the classes (using CTRL+click on the XML tag goes right to the correct class) , it just doesn't seem to find them while viewing.

i've also tried to uninstall ADT and reinstall it, but it didn't help. i've also tried to uninstall and re-install some relevant components from the SDK manager. nothing helped.

here's a sample code of a custom view that doesn't show well at all :

public class CustomTextView extends TextView {

    public CustomTextView(Context context) {
        super(context);
    }

    public CustomTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
}

as you can see, there is nothing special in this code.

The question

Why does it occur? how can i fix it? can i perhaps copy all (and i mean all) the settings of the current workspace to a new one to solve it?

Does anybody else have this problem? is it an ADT bug?

NOTE: I do not want to reset the workspace. it has far too many special settings for the projects within it.

Traditor answered 8/8, 2013 at 7:7 Comment(4)
Do you mean the preview in the Graphical Layout section of the xml?Federicofedirko
@user2012 yes. the one that you sometimes use isInEditMode in case your custom view can't be shown , so you put fake stuff.Traditor
@androiddeveloper: I don't have this kind of problem. can you post example of "simple" custom view that behaves like that in layout editor?Sora
@TalKanel as i've written, even the simplest custom view won't show, but it's only for this workspace. if i use a totally new workspace, everything works just fine. as an example, i've posted now a sample class, but any class that you can think of won't work.Traditor
G
0

Did you also update the Eclipse plugin together with the ADT?

I know this happened to me once it was probably what i missed.

Maybe if there are updates to the actual platform SDK's update them as well. you can also try to change the version of the SDK the preview uses to the latest or earlier one (this is the android icon on the top left in the preview which should say 18).

I know that some custom views don't render if you use shadows for example on text. Then you just set the isInEditMode flag inside the custom view to skip those.

At the very end download a new zip with the ADT bundle and try again :)

Hope this helps somehow.

Gravelblind answered 19/8, 2013 at 18:32 Comment(4)
sadly, i've already tried those things. it's not related to shadows since i've tested it even on the sample code i've written (plus for other custom views which do contain shadows, i've used the function you mentioned and they worked just fine before this bug). i wish i could revert to ADT&SDK 17 just for this issue alone. i have a lot of custom views and it's hard to imagine how everything looks like ...Traditor
Well you can revert to sdk 17 as i mentioned above, you can also install an earlier ADT from a zip file.Gravelblind
wouldn't it take a lot of hours just to wait for it to download all that it needs? i already know that ADT&SDK 18 work fine on my home computer , so it might be a huge waste of time.Traditor
Its like 400 megabytes. if your connection is dial up it will take a long time :)Gravelblind
G
0

Have you included the other workspace library into the new project? E.g. Project->Properties->Android->Library "Add" the old workspace project.

Greenwich answered 21/3, 2016 at 23:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.