0

I need to write "tingting" in an editbox in my application.first i wrote ting after that i copied the text and paste it in the same editbox.but the value in the edit text is "ting ting".
.I know how to remove whitespace while taking the value from edit text.but i want to remove the whitespace while pasting text in the edit box
how can i do that? given below is my edittextbox.

 <EditText
        android:id="@+id/list_AddNewtext"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@drawable/list_stdcenterelement"
        android:imeOptions="actionSend|actionGo|actionDone"
        android:inputType="text|textCapWords"
        android:padding="5dp"
        android:textColor="@android:color/black"
        android:textSize="14sp"
        android:textStyle="bold"
        android:visibility="visible"
        android:maxLength="1000" />
andro-girl
  • 7,989
  • 22
  • 71
  • 94

2 Answers2

0

Try

String str=list_AddNewtext.getText().trim();
list_AddNewtext.setText(str);
GAMA
  • 5,958
  • 14
  • 79
  • 126
0

try this one

String str = list_AddNewtext.getText().toString();
String _newstr = str.replace(" ", "");

use _newstr its give tingting output

you put this code in your onclickListner event

Piyush
  • 3,061
  • 8
  • 34
  • 52