I have a button, with the ID button1.
When you click the button, it opens another activity, where you can enter in text, when you press the back button again, it saves the text and displays is on the button. But I only want the first 10 or so characters to show on the button. Is this possible?
Here is some code:
Button item1 = (Button)findViewById(R.id.button1);
item1.setText(PrefConnector.readString(this, PrefConnector.ONE, null));
The conect of the string PrefConnector.readString(this, PrefConnector.ONE, null) is very long, about a paragraph. So I only want the first 10 characters to appear on the button, and if possible an ellipse on the end to show that there is more text.
Thanks
To modify the String itself use
substring():Alternatively, you should also be able to define a maximum width in your Button’s XML and allow it to use ellipses when necessary: