替換字符串我試圖用一個縮短的URL替換字符串內的URL:問題在Java中
public void shortenMessage()
{
String body = composeEditText.getText().toString();
String shortenedBody = new String();
String [] tokens = body.split("\\s");
// Attempt to convert each item into an URL.
for(String token : tokens)
{
try
{
Url url = as("mycompany", "someapikey").call(shorten(token));
Log.d("SHORTENED", token + " was shortened!");
shortenedBody = body.replace(token, url.getShortUrl());
}
catch(BitlyException e)
{
//Log.d("BitlyException", token + " could not be shortened!");
}
}
composeEditText.setText(shortenedBody);
// url.getShortUrl() -> http://bit.ly/fB05
}
鏈接之後被縮短,我想打印在一個EditText修改後的字符串。我的EditText沒有正確顯示我的消息。
例如:
"I like www.google.com" should be "I like [some shortened url]" after my code executes.
什麼打印到EditText? – Haphazard 2011-04-27 17:11:07