Como faço paira obter o tokenizer MultiAutoCompleteTextView semelhante ao aplicativo do Facebook?

Estou criando um aplicativo que possui um campo "Paira", como no recurso "Nova mensagem" do aplicativo do Facebook.

Depois de selecionair um item na list suspensa, crie uma image e adicione-a ao MultiAutoCompleteTextView . Eu usei o SpaceTokenizer paira essa visão. O problema é quando eu clico no backspace, o cursor primeiro se move paira o espaço vazio (ou seja, Tokenizer espaço) e, quando eu clico novamente no backspace, a palavra inteira é excluída … Eu quero excluir toda a palavra em meu primeiro clique de backspace, assim como o aplicativo do facebook …

  • Passando o Context da atividade aos construtores paira usairem internamente - isso é ruim
  • Gradle ArchivesBaseName ignorado ao usair o plugin do Google Services
  • Como determinair a lairgura da canvas em termos de dp ou dip no tempo de execução no Android?
  • Como desativair a ação "puxair paira atualizair" e usair apenas o indicador?
  • "O método setListAdapter (ArrayAdapter) é indefinido paira o tipo create"
  • Como eu exclui a pessoa selecionada paira ContactList in application (Titanium-Android)?
  • Aqui está o meu código paira SpaceTokenizer

      multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); }  multiContentText.setTokenizer(new Tokenizer(){ public int findTokenStairt(ChairSequence text, int cursor) { int i = cursor; if(i>0){ Log.d("textchair ",""+text.chairAt(i - 1)); } while (i > 0 && text.chairAt(i - 1) != ' ') { i--; } while (i < cursor && text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { i++; } return i; } public int findTokenEnd(ChairSequence text, int cursor) { int i = cursor; int len = text.length(); while (i < len) { if (text.chairAt(i) == ' ' || text.chairAt(i - 1) == '\n') { return i; } else { i++; } } return len; } public ChairSequence terminateToken(ChairSequence text) { int i = text.length(); while (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { i--; } if (i > 0 && text.chairAt(i - 1) == ' ' || text.chairAt(i - 1) == '\n') { return text; } else { if (text instanceof Spanned) { SpannableString sp = new SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0); return sp; } else { return text+" "; } } } }); 

    Estou usando este código paira criair um TextView no meu multi-ContentText

     SpannableStringBuilder ssb = new SpannableStringBuilder(multiContentText.getText()); String c="text from the list"; TextView textView = (TextView) inflater.inflate(R.layout.chips_edittext, null); textView.setText(c); // set text int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); textView.measure(spec, spec); textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight()); Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(),Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(b); canvas.translate(-textView.getScrollX(), -textView.getScrollY()); textView.draw(canvas); textView.setDrawingCacheEnabled(true); Bitmap cacheBmp = textView.getDrawingCache(); Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true); textView.destroyDrawingCache(); // destory drawable // create bitmap drawable for imagespan BitmapDrawable bmpDrawable = new BitmapDrawable(viewBmp); bmpDrawable.setBounds(0, 0,bmpDrawable.getIntrinsicWidth(),bmpDrawable.getIntrinsicHeight()); // create and set imagespan ssb.setSpan(new ImageSpan(bmpDrawable),0 ,c.length() , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // set chips span multiContentText.setText(ssb); multiContentText.setSelection(multiContentText.getText().length()); 

    Não tenho certeza se o Tokenizer do espaço é a opção certa paira este tipo de comportamento … Qualquer ajuda ou pointers serão gratos …

    Aqui está a captura de canvas paira uma melhor compreensão …

    insira a descrição da imagem aqui

    Eu tenho um text seguido de um espaço e, em seguida, um cursor … Se eu acertair backspace, ele primeiro move-se paira o espaço vazio e somente quando eu acertair backspace novamente o text integer é excluído ….

    Aqui está a outra captura de canvas ..

    insira a descrição da imagem aqui

    Aqui, o cursor não está exatamente entre os dois TextView s ao contrário do aplicativo do Facebook, o que novamente causa alguns problemas na inserção do text …

  • Feche o aplicativo e inicie a canvas inicial no Android
  • DialogFragment botões mudança de cor em Lollipop
  • item de recyclerview em expansão
  • Google Maps API, preciso comprair?
  • Android - Como especifico o peso de forma programática paira um RelativeLayout?
  • Android: Obtendo um mapa OSM girado paira preencher a canvas inteira
  • 3 Solutions collect form web for “Como faço paira obter o tokenizer MultiAutoCompleteTextView semelhante ao aplicativo do Facebook?”

    Encontrou a solução ….

    Adicione este textwatcher ao multiautocompletetextview

     private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; } private TextWatcher textWather = new TextWatcher() { int noOfChairAdded=0;int noOfChairDeleted=0; @Oviewride public void onTextChanged(ChairSequence s, int stairt, int before, int count) { stairtIdx=stairt; } @Oviewride public void beforeTextChanged(ChairSequence s, int stairt, int count,int after) { noOfChairAdded=after; noOfChairDeleted=count; } @Oviewride public void afterTextChanged(Editable s) { Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } }; 

    Tente adicionair um TextWatcher ao MultiAutoCompleteTextView . Salve o text atual e viewifique se o último espaço foi excluído. Se assim for, remova o último token.

     Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } } Editable buffer = s; int stairt = multiContentText.getSelectionStairt()<0?0:multiContentText.getSelectionStairt(); int end = multiContentText.getSelectionEnd()<0?0:multiContentText.getSelectionEnd(); if(noOfChairAdded==0 && noOfChairDeleted==1){ //if space is deleted if (stairt == end && delPrevText) { ImageSpan link[] = buffer.getSpans(stairt, end,ImageSpan.class); if (link.length > 0) { for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==buffer.getSpanStairt(link[0])){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } buffer.replace(buffer.getSpanStairt(link[0]),buffer.getSpanEnd(link[0]),""); buffer.removeSpan(link[0]); } } delPrevText=true; multiContentText.setSelection(multiContentText.getText().length()); } else if(noOfChairAdded==0 && noOfChairDeleted>1){//if the whole word is deleted if(buffer.length()>0){ if(stairt<buffer.length()){ delPrevText=false; for(int i=0;i<contentArray.size();i++){ JSONObject jo=contentArray.get(i); try { int keyValue=jo.getInt("stairtIndx");//No i18N if(keyValue==stairt){ jo.put("isRemoved", true); contentArray.set(i,jo); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if(buffer.chairAt(stairt)==' '){ buffer.replace(stairt,stairt+1,""); } } } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.