I'm developing a little game with libgdx and in my about screen I would like to have a label (wrapped in a table) in which there would have a clickable text link (underlined or with a different color) like this:
You can review the code here
Edit:
What I've tried is:
HorizontalGroup monGroup = new HorizontalGroup();
Label howRotationRep = new Label("They have been based on the information provided on this ", new Label.LabelStyle(game.petiteFont, Color.WHITE));
howRotationRep.setWrap(true);
howRotationRep.setWidth(tailleCell);
Label test = new Label(" site", new Label.LabelStyle(game.petiteFont, Color.RED));
test.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.net.openURI("http://tetrisconcept.net/wiki/SRS");
}
});
monGroup.addActor(howRotationRep);
monGroup.addActor(test);
table.add(monGroup).left().width(tailleCell);
And it gives me this
If you need only a portion of the Label clickable, I think the best way to implement this is having two Labels, this should work:
Label lblReviewCode = new Label("You can review the code ", skin);
Label lblReviewCodeLink = new Label("here", skin, "linkstyle");
// If you don't want to provide a custom style...
//Label lblReviewCodeLink = new Label("here", skin);
lblReviewCodeLink.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.net.openURI("https://bitbucket.org/batman3000/batris");
}
});
// If you didn't provided the style, you can at least paint it blue by doing this...
//lblReviewCodeLink.setColor(Color.BLUE);
HorizontalGroup codeLink = new HorizontalGroup();
codeLink.addActor(lblReviewCode);
codeLink.addActor(lblReviewCodeLink);
table.add(codeLink);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With