You can go with getSmiley(1).toString(). it will work ?
Like message1=message1.replaceFirst("x-\(R", getSmiley(1).toString());
Frage
I am making a chat application in which I am using emoticons functionality. My emoticons are working properly but the problem is:
When I send only one smile, it works properly
I want to send more then one image in edittext or dialog, here is image snapshot:
Here is my code:
builder = new SpannableStringBuilder(message1);
if(message1.contains("x-(R"))
{
int len=message1.indexOf("x-(R");
while(len!=-1)
{
builder.replace(len, len+4, getSmiley(1));
message1=message1.replaceFirst("x-\\(R", "");
len=message1.indexOf("x-(R");
}
}
For sending and showing the image, where am I going wrong?
Lösung
You can go with getSmiley(1).toString(). it will work ?
Like message1=message1.replaceFirst("x-\(R", getSmiley(1).toString());
Andere Tipps
The only problem I see is that you replace a string in the builder
with getSmiley(1)
(assume this is not empty string), then in message1
you replace X-R(
with empty string. message1
and builder
are not in sync anymore after the first replace. So when you get the len
for second time ( len=message1.indexOf("x-(R");
) you replace wrong index in the builder
.
Maybe the correct thing to do is to replace the message like the builder:
message1=message1.replaceFirst("x-\\(R", getSmiley(1));