I have edittext like below
<com.myapp.example.customview.socialView.SocialEditText
android:id="@+id/edt_des"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:afterTextChanged="@{(editable)->viewModel.onDescriptionTextChanged(editable)}"
android:background="@drawable/bg_white_corner_15"
android:backgroundTint="@color/colorPrimaryDark"
android:elevation="5dp"
android:fontFamily="@font/popins_reguler"
android:gravity="top"
android:hint="@string/upload_description"
android:maxLength="175"
android:padding="10dp"
android:textColor="@color/light_white"
android:textColorHint="@color/color_text_light"
android:textCursorDrawable="@xml/cursor"
android:textSize="12dp"
app:socialFlags="hashtag" />
and in viewmodel function for get text like below
public void onDescriptionTextChanged(CharSequence text) {
postDescription = text.toString();
position.set(postDescription.length());
}
I have one function which can remove the word from String like below
public void main(String[] args) {
String word = postDescription;
String remove = "#WordForRemove";
finalDescription = removeWords(word, remove);
}
public static String removeWords(String word ,String remove) {
return word.replace(remove,"");
}
I want to use this function with onDescriptionTextChanged so I can remove unacceptable words from edit text, Let me know if anyone here can help me for achieving it.
Thanks!