I am trying to set the caption of a checkbox and i want to break at a certain point in the string to create a new line without waiting for the word wrap:
When i added the simple \n character to caption string it did not work.
private CheckBox completeCheckbox;
completeCheckbox.setCaption("why wont this\n break");
I just had the same problem and the simple solution for this was to call "setCaptionAsHtml(true)" on the CheckBox instance and to set the caption using HTML code.
private CheckBox completeCheckbox = createMyCheckboxSomehowFunction();
completeCheckbox.setCaptionAsHtml(true);
completeCheckbox.setCaption("why wont this<br/>break");
The above code snippet should do what you want. At least it worked fine for me.
i think the solution is to use an Option Group
I just read that here
Related
I am working on modifying EGit for an use case. The current state looks like the following:
I now want to add an image next to the title text of the unstaged section i.e. next to "Unstaged Changes (0)". Check the following for reference:
I am not looing to add image to the toolbar, but next to the text.
Check the following code for the current unstaged section:
Section unstagedSection;
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
unstagedSection = toolkit.createSection(parent, ExpandableComposite.SHORT_TITLE_BAR);
unstagedSection.setText("Unstaged Changes" + " (0)"); //$NON-NLS-1$
unstagedSection.clientVerticalSpacing = 0;
GridDataFactory.fillDefaults().grab(true, false).applyTo(unstagedSection);
Composite unstagedComposite = toolkit.createComposite(unstagedSection);
toolkit.paintBordersFor(unstagedComposite);
GridLayoutFactory.fillDefaults().applyTo(unstagedComposite);
unstagedSection.setClient(unstagedComposite);
I want to know if it is possible to add the image next to the title text of the Section and how?.
Any kind of help will be appreciated. Thanks.
Edit 1:
I have reached till this point. The only thing I need to know is how to put it right after the text.
I have designed the GUI elements and put everything together using CodeName One plugin for Netbeans 8.1. I am first working on my client information GUI that has textfields and a submit button. I'm looking to retrieve the textfield imputs via the submit button action event(I will use the first name textfield as an example:
#Override
protected void onAddRecordGUI_SubmitButtonAction(Component c, ActionEvent event) {
..I tried this
String Fname = findTxt_Firstn(c).getText();
..I also tried this
String FirstName = findTxt_Firstn.getText();
..I then tried this
String FirstName = Txt_Firstn.getText();
}
I get "error: cannot find symbol" with regards to the textfields name (It is correct and located on the same form the button is located)
Am I doing something very wrong here? I found two post on Stack, however, I tried the solutions above anyway.
Okay! I have solved my own questions and this might be applicable to anyone else who encounters this issue. The issue isn't the code, but it is naming textfields with an underscore "_". I renamed the field and was able to create a reference to it.
Thanks.
Recently I want to get specific line text in a textview and I want to use a webview to load the text,I ve found some code references which I think is useful but not work for me well.
Textview:
A
Http://ABC.com.jp
C
I want to load line 2 URL.
Sorry for my low responsibility, now I still updating and modifying my source code,I am new in java and this is not my main profit,besides I will keep learning.
Target =(TextView)findViewbyid(R.id.abc);
myTextView = (TextView)findViewbyid(R.id.id1);
int startL= myTextView.getLayout().getLineStart(2);
//^start line
int endL = myTextView.getLayout().getLineEnd(3);
//^end line
String getResults = myTextView.getText().substring(startL, endL);
Target.setText(getResults);
//benefits of using get line end & start is that it can select multiple line content from a large content,also it can be used in selecting single line or specific line.
I have an xml which Text looks like this :
<LINE>here is some text, it is going,going, and then return is pressed
and the text is going from the next line</LINE>
now when I do :
XmlPullParcer xpp;
//then all the parcing, try/catch stuff, finding needed tag
String s=xpp.getText();
myTextView.setText(s);
(of course, I cut all the code, but you got the idea)
what I see on the screen is not one solid line with no formatting as I wish, but the same two-line text
So, what I see on the screen is :
here is some text, it is going,going, and then return is pressed
and the text is going from the next line
and I want :
here is some text, it is going,going, and then return is pressed and but text is going in one line
please tell me how can I process my String s so it can be shown in a TextView in one line
It looks like the line in XML itself is having a line feed or carriage return. So try to replace them with empty string via String replace method. You can refer to link below for more details:
http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#sum
Also make sure the TextView in layout has singleline attribute set to true and layout_width set to match_parent.
input.replace("&", "&").replace("<", "<").replace(">", ">").replace(""", "\"");
im using this line of code as a sudo htmlspecialchars converter. with my application, it doesnt need to be too elaborate.
for some reason the above code does not replace("&", "&"), it doesnt seem to do anything.
any advice?
input = input.replaceAll("[^\\x20-\\x7e]", "");
i also tried this.
In android there is one class Html inside android.text.Html which you can use like this as below:
Html.fromHtml(any_html_text);
But this function will return Spanned object so use
Spanned spn=Html.fromHtml(any_html_text);
You can set this spanned text to any button or textview text Hope it will help you.
See this link also for your reference.
Instead of doing this manually, check out the Html class. Calling Html.fromHtml() should do the trick.
Trying to escape/unescape html by replacing strings yourself you might introduce security issues in your application (depending on what it does with the output). Either use Html.FromHtml or from Apache libs org.apache.commons.lang.StringEscapeUtils.unescapeHtml
This does the work -
public String cleanString(String dirty) {
return Html.fromHtml(dirty).toString();
}