I've been using Html.fromHtml to display html text into a TextView but am not completely happy primarily because it doesn't support bullet points (li, ol).
I've run across HTMLSpanner (at https://github.com/NightWhistler/HtmlSpanner) and it looks like something worthwhile exploring.
Trouble is, I'm using Eclipse and, being somewhat new to this world of java, am not clear as to how to incorporate that code into my project.
I have incorporated other private libraries (like sqliteassethelper & photozoom), but HTMLSpanner is confusing me.
Can anybody help?
Right, after getting help from the author of HtmlSpanner (Alex Kuiper), here's what needs to be done:
Retrieve Jars. You need HtmlSpanner and HtmlCleaner. These can be acquired from the Pagecleaner repo (use the latest version) and here (note: HtmlCleaner versions above 2.2 will NOT work)
Add them into your project as "External jars" (Properties -> Java Build Path -> Libraries -> Add External Jars). Also check them in "Order and Export"
Modify code. Replace Html.fromHtml() with new HtmlSpanner().fromHtml() as in tv_question.setText(new HtmlSpanner().fromHtml(mtext));
I needed HtmlSpanner primarily for the additional "list" functionality, so I've been focusing on that ... and found a few minor issues:
Nested lists. Need to add a break at the start of the child, as in <ol><li>This is part of the parent list <br><ul><li>First child list item"
Regular text following list. Need to add a paragraph break plus a regular break to get the single-line gap. As in ...list ended.</li></ul><p><br>Regular paragraph started...
The numbered list. Does not provide a blank after the "number.". As in, <ol><li>Apples (and all subsequent list items) will show up as "1.Apples", not "1. Apples". I have not found a workaround for this.
Underline. <u>...</u> does not work.
My environment: Ubuntu 12.04, Eclipse 4.2.1 (Juno), Android API 20
Overall, a fantastic set of classes that I am thrilled to have access to. Many thanks, again, to Alex.
Related
An external java library is treated as "package only containing non Java resources" (as indicated by the white icons as opposed to brown; the description in quotes is taken from here). When I try to import the library it cannot be resolved, so it seems it really isn't being recognised (in other words it's not just a case of eclipse showing wrong icon).
Two people have commented that my screenshots are not helping, so let me explain the intention behind them. The first one above is to show the difference between how my libraries are displayed. Htmlparser is a folder with .java files just like SPMF and works fine. Commons-lang and vecmath are .jars. SPMF cannot be resolved when I try to import it. The reason the screenshot is cropped this way is to highlight that all of the folders in SPMF are showing white which apparently means they are not recognized.
This is only the second time I'm using an external library, but I think I did everything the same as the first time.
This screenshot is intended to show how SPMF is added at the moment.
The library I am trying to add is SPMF - more specifically the Hierarchical Clustering algorithm. This is only a minor component of SPMF but it's the best Hierarchical Clustering solution I could find. It works fine if I just import it into a new project. So I could just bodge it by moving my code into that project if I can't get it going otherwise.
I presume that if a package can form a standalone project then it can also be used as an external library - or am I wrong?
I'm sure it's a stupid mistake I'm making but I've had no luck with google. This is the nearest I could find; Refresh seems the only applicable solution and it doesn't help.
Edit, SPMF is also available as a jar, it's missing some features but not the ones I need. I've been able to add the jar and the import the algorithm I need. It's enough of a workaround for me to move on and keep going. But it's not a solution and the question remains open.
I just discovered that my NetBeans suddenly stops importing classes that are found in the Java API but can still import classes from my external libraries. Take a look at the image below:
As you can see, List and ArrayList are classes from the java.util package but the usual suggestions for importing them are not shown here, instead it is asking me to create class. I know that I can type import java.util.List; on the top of the code but life was better before! Please I need help thanks.
I had the same problem a couple minutes ago... Terrible. The same problem has been reported here:
Bug 235712
The solution which I've found there was sufficient - simply delete the Netbeans cache...
In order to do this, go to Help ==> About . Then go to the directory with cache and delete all you find in the "index" catalog.
After restarting the NB, everything was cool.
Today I came across the same problem. It happens that it actually is very easy to exclude a class from code completion if you click in the wrong place while working.
To solve it (netbeans 8.2) go to
Tools - Options -> Editor tab
Then select Code Completion Tab
In the drop Down select JAVA (in my case it was Java)
You will find a box bellow titled Package/Classes
In the EXCLUDE tab you probably will find the packages marked to be excluded from code completion. Just remove the ones you want back.
Check under Preferences->Editor->Code Completion to make sure auto complete is on, though by your screen shot I assume that it is.
Also try Preferences->Editor->Formatting and set your Language to Java
In my case, NetBeans was refusing to suggest Scanner. As it turned out, all I had to do was remove java.util.Scanner from Options » Editor » Code Completion » Packages/classes: » Exclude. Then the autocompletion for Scanner returned.
I want to write a plugin which will give me content assist support and work in JSF. I want it to work like the sample below :
I'll type "p:button action="#{
Then I'll press "Ctrl+Shift+Space" (for example)
It'll read the classes in my project and show them as a list in a pop-up window
Then I'll select one class. It'll be like below
h:button action="#{MyClass
When I type "." , It'll read the methods in my selected class and show them as a list in a pop-up window.
Then I'll select a method
Finally, It'll end like this "h:button action="#{MyClass.MyMethod}
Do you have any idea, how can i do this? Any suggestions?
One place to look for an example of content assist is to look at XText which already has this feature for DSL-like languages.
See the XText sources in its Git repository: by looking work the log message 'assist', you will have a list of commits all related to content assist implementation, like the XbaseProposalProvider.java class.
The following are both screenshots from the Web Page Editor which comes with the Java EE edition of Eclipse.
You can install it by adding the following mirror to your Eclipse repository. Change the name depending on what version you use. For Helios it is http://download.eclipse.org/webtools/repository/helios.
I have been wracking my brain trying to figure this out. For the first time I used jEdit the other day and I was pleasantly surprised that it auto indented my code (meaning that I'd put in the following code:
int method () {
_ //<-- and it put me here automatically
I've tried to get the same thing working with eclipse but with no success. I got into the code formatter but I don't see how to make that happen.
Is it possible to do this? Also while I'm here, is there a such thing as a eclipse plugin that will allow you to search the methods and classes of the standard java library?
Thanks
Personally all I use for this is the format options Window->preferences under Java->Code Style ->Formatter.
I once took the time to tweek how I like my code to look like when I work and exported the whole thing. After that I just code without too much bother on what it looks like. When I find the code looks messy by pressing the combination ctrl+shift+f and the whole class becomes pretty again, comments and all.
After a while it pretty much became a reflex...
code code code
ctrl-s, ctrl-b (cause I disable auto build sometimes), ctrl-shift-f
code some more etc...
Once I got used to this I never really cared how it presented the code as i was typing because I knew it would look all pretty as soon as the loop/if/switch/method etc is finished
My clean eclipse install does this by default.
Have you changed any options? Make sure the file you are editing has the .java file extension. The preference options that control the typing automations are under Java -> Editor -> Typing in the Window -> Preferences menu.
Also, I find that the auto-indenting, and most of the other auto-complete functions of eclipse do not function well if the file I am editing has errors in it which prevent compilation. Make sure that your curly-braces are matched correctly, this is the main one that I've noticed blocks auto-indent.
Regarding searching through the standard Java libraries, use the Search -> Java.. menu option, and check the JRE libraries checkbox, then search away. You can also use the Hierarchy view to see how the classes relate. Also, in the Package and Project views you can expand the JRE System Library, and then expand rt.jar which holds pretty much all the standard Java pacakges.
Eclipse has always done this for me by default.
One really cool thing about eclipse is that you can search preference pages. Just right click and go to prefrences. Go to the "Window" menu, and click "Prefrences". Then at the top of the tree view there's a text box that says "type filter text". Replace that with "indent" and it should bring up the page where the indent option is.
Make sure that eclipse recognizes your file as a java file, that you're using the Java distribution, the latest version, etc.
Iv been trying to work around the eclipse indenting and other supposed features for years, and it seems that the bottom line is this ...
It only works for the programming style of the authors, so to use it you need to modify your style to comply.
This would be OK except that the authors of eclipse have some very strange ideas about common shortcut keys.
One horrid example is the search features, eg when did Ctrl+K become "Find Next occurrence" and why doesnt F3 or n work?
That all being said I use eclipse because if you have the time to wait around while it starts up - or never close it - and you can modify everything youve learned about using an editor - why why why - then it will certainly increase your efficiency.
Please note that there is a preference setting for indenting, it can be set for a project, a workspace, or globally, but no matter how you set it eclipse will still chuck tab characters in where you dont want them.
In fact its indent crazy, like it wants to indent everything, even if its already indented.
Like I said Iv been using it for years and it STILL drives me nuts with its random behavior.
Follow these steps for Eclipse:
Select all text: ctrl+A
Correct indentation: ctrl+I
You should check:
Hidden features/tricks for Eclipse?
What is your favorite hot-key in Eclipse?
I just started using eclipse for some personal projects and am finding the transition from IntelliJ (what I use at work) kind of annoying. I hope it's kosher to ask a few different questions in the same thread. Here goes:
1) How do I get "views" (I'm not sure if this is the term. I mean windows such as Project Explorer, Servers, Console, etc) to stay expanded and on top even after I've clicked back on the editor or another view. I'm pretty sure that right now all of these tabs are "quick views" that I have minimized and then docked, so I may not be doing this right to begin with. In IntelliJ, I would simply just pin the tab.
2) How can I open a file (for instance, an ant build.xml) without having to make it part of an eclipse project? I want the syntax highlighting and Ctrl-click ability that the IDE will give me (not to mention being able to use eclipse's built-in ant), but I don't need to associate the file with any others and so don't see the point of having to make it a part of a project.
3) Is it just me (wouldn't be surprised) or does eclipse have a bug with parsing empty html tags within the body of html tags of the same type. I've only tested this in a JSP, and it doesn't happen with JSF tags. For example: <div id="foo"><div id="bar"/></div>. Eclipse will give a warning saying the first div tag has no end tag. This is with the most recent version of eclipse for Java EE, no plugins have been installed.
4) Finally, a general question: Any best practices or resources to look at for organizing the eclipse interface and perspectives/views? What about workspaces/projects? Is there some tutorial out there that would be really informative that I could read through in less than an hour?
I appreciate any answers and tips/tricks.
First of all, please acknowledge that there are different people in the world and there are people who don't work the "Eclipse way". Even if I was paid for it (and I am), I couldn't work with IDEA. So if Eclipse rubs you the wrong way, it may not be for you. That out of the way, your answers:
In Eclipse, you open a view and let it stay where it is. In IDEA, the view changes all the time, things pop up and go away. Eclipse is static unless you specifically move things around. There are two ways to move things: You can minimize a part (a part is something which contains tabbed views). This moves the part into the closest border. Or you can maximize the current part (Ctrl-M). This pushes all other parts out of the way. Another Ctrl-M will restore the view.
This is a good place to show the difference between IDEA and Eclipse. IDEA tries to anticipate what you're doing and to be helpful. For me, this means it always gets in my way. It will start to format source as I type, things move, etc. That freaks me out. Eclipse is like a toolbox. Everything is there but you have to pick it up. A toolbox doesn't move on its own accord and it doesn't try to be smart.
Eclipse is based on the idea of a workspace. The workspace is the universe and nothing outside exists. If you need to go outside, you must first create a file or folder. In the "New File/Folder" wizard, you can open the advanced options (at the bottom) and link this resource to a real file/folder in the file system. May sound like a lot of effort but it allows Eclipse to display virtually anything in the explorer since it just shows "resources" in there, not actually files.
Smells like a bug. Please report it at https://bugs.eclipse.org/bugs/
I'm not aware of anything.
[EDIT] 3. As cletus pointed out, is not valid HTML. So that might cause the warning.
An Eclipse Perspective is a collection Views and their position. You can customize or create new perspectives, but the existing ones are good enough for a start (Java, J2EE, Java Browsing etc.). I recommend to stick with the default layout for a while until you've managed to use the quick view feature (which, personally, i find quite annoying). On small screens, i simply like to use Ctrl-M to switch the Editor to fullscreen mode and back, without the need of minimizing single views or move them around.
Yes, you can run external build scripts as well and it's called External Tool in Eclipse. Go to Run > External Tools > External Tools Configurations. Create either a new Ant-based config or a native executable (Program). The location of the build script or executable can either be workspace-relative (Browse Workspace) or absolute on the file system (Browse File System)