TextWatcher crash when get edittext - java

After I type, it gives me the message: your app isn`t responding.
do you want to close it?
WAIT OK
I think because of the edt_search.gettext().tostring() inside the setData()
private void setupViews() {
edt_search = findViewById(R.id.edt_search);
progress = findViewById(R.id.progress);
progress.hide();
edt_search.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void afterTextChanged(Editable editable) {
if (editable.length() != 0) {
setData();
}
}
});
}
private void setData() {
AndroidNetworking.post("uri")
.addBodyParameter("word", edt_search.getText().toString())
.build()
.getAsObjectList(Search.class, new ParsedRequestListener<List<Search>>() {
#Override
public void onResponse(List<Search> searches) {
for (Search search : searches) {
searchList.add(search);
adapter.notifyDataSetChanged();
}
loading(false);
}
#Override
public void onError(ANError anError) {
Log.e("android-networking", "error: " + anError.getLocalizedMessage());
}
});
}

You are probably guessing it right. By empiric experience, I found out it's problematic to call methods from EditText inside afterTextChanged method (at least without removing the text watcher first). If possible, it's much better to use the Editable object that is passed as an argument. So, in your case, you could try two approaches:
First (easiest and which I most recommend in this specific case): Pass your string to the method setData(), so you don't need to access your EditText in this method:
....
#Override
public void afterTextChanged(Editable editable) {
if (editable.length() != 0) {
setData(editable.toString());
}
}
....
private void setData(String searchString) {
AndroidNetworking.post("http://akhbaresteghlal.ir/search/getInformations.php")
.addBodyParameter("word", searchString)
.build()
....
Second option (if, by any reason, you absolutely need to access your editText directly): Remove the TextWatcher before calling setData() (and any method from EditText) and then add it again after.
....
#Override
public void afterTextChanged(Editable editable) {
if (editable.length() != 0) {
edt_search.removeTextChangedListener(this);
setData();
edt_search.addTextChangedListener(this);
}
}
....
private void setData() {
AndroidNetworking.post("http://akhbaresteghlal.ir/search/getInformations.php")
.addBodyParameter("word", edt_search.getText().toString())
.build()
....
Hope it helps!

Related

How to display data in textview automatically when i have finished inputting the ID field?

so i have edittext & textview. edittext for NIK & textview for NAMA. the concept is when I have finished typing the NIK field, then at that moment the name data (NAMA) appears in the textview automatically based on database. I still confused how to do it properly.
Database Structure
NIK
NAMA
96296
Farrasta
94878
Alfian
Edit Text
etNik.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String data = etNik.getText().toString();
if (data == NikKry){
getNama();
}
}
#Override
public void afterTextChanged(Editable s) {
}
});
Function for get NAMA
private void getNama(){
APIRequestData armNama = RetroMaster.konekRetrofit().create(APIRequestData.class);
Call<List<DataMaster>> tampilNama = armNama.ardGetNama(NikKry);
tampilNama.enqueue(new Callback<List<DataMaster>>() {
#Override
public void onResponse(Call<List<DataMaster>> call, Response<List<DataMaster>> response) {
if (response.isSuccessful()) {
tvNama.setText(response.body().get(0).getNAMA());
}
}
#Override
public void onFailure(Call<List<DataMaster>> call, Throwable t) {
Toast.makeText(TambahActivity.this, "Gagal "+t.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}

How to set constant animation after EditText reach target length?

I want to set animation on ImageView when user put more than 3 characters. I wrote a code to do this. Main problem is when I keep putting more than 3 characters the animation starts again from 0 position always when new character is added, so it doesn't looks good.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_user_first);
initViews();
imageButtonNext.setEnabled(false);
horizontalScrollView.post(() -> horizontalScrollView.scrollTo(0, 0));
horizontalScrollView.setOnTouchListener((v, event) -> true);
editTextEnterName.addTextChangedListener(nameTextWatcher);
pulse = AnimationUtils.loadAnimation(NewUserFirst.this, R.anim.pulse);
imageButtonNext.setOnClickListener(view -> {
intent = new Intent(this, NewUserSecond.class);
startActivity(intent);
});
}
public void buttonAnimation(){
if(buttonBoolean){
imageButtonNext.setAnimation(pulse);
imageButtonNext.setColorFilter(ContextCompat.getColor(NewUserFirst.this, R.color.accent));
imageButtonNext.setEnabled(true);
} else {
imageButtonNext.clearAnimation();
imageButtonNext.setColorFilter(ContextCompat.getColor(NewUserFirst.this, R.color.gray));
imageButtonNext.setEnabled(false);
}
}
private final TextWatcher nameTextWatcher = new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
nameInput = editTextEnterName.getText().toString().trim();
if (nameInput.length() >= 3) {
buttonBoolean = true;
} else {
buttonBoolean = false;
}
}
#Override
public void afterTextChanged(Editable editable) {
buttonAnimation();
}
};
So the question is, what changes I need to make in my code to set animation, and do not renew it every time when add next character.
Here is the answer:
public void buttonAnimation(){
if(buttonBoolean){
if (!imageButtonNext.isEnabled()) {
imageButtonNext.setAnimation(pulse);
imageButtonNext.setColorFilter(ContextCompat.getColor(this, R.color.accent));
imageButtonNext.setEnabled(true);
}
} else {
imageButtonNext.clearAnimation();
imageButtonNext.setColorFilter(ContextCompat.getColor(this, R.color.gray));
imageButtonNext.setEnabled(false);
}
}
We need to add if statement in animation method. Program check animation is currently enabled, when yes, program do nothing. Result is animation triggered once live his own life until we modify edittext to length less than 3.

Suggest text for edittext look like search of chrome

I have edited the text and list of results obtained from the search. Now I want to set first result for edittext, it looks like below
this is code i use to get result search:
bindingNV.etSearch.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(s.toString().length()>0){
new SearchFlowWord(new NotifyDataChangeListener() {
#Override
public void dataChange(List<String> mList) {
if (mList.size()>0) {
resultSearch = mList.get(0);
}else {
resultSearch ="";
}
}
}, s);
}
}
#Override
public void afterTextChanged(Editable s) {
}
});
How i can set edittext like image

How to disable button with multiple edit text using Textwatcher?

I am trying to disable my button if my input edit texts are empty. I am using text watcher for this. To test it out , i have only tried with only two edit texts to start.
However, my button stays enabled no matter what.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_profile);
fnameInput = findViewById(R.id.et_firstname);
lnameInput = findViewById(R.id.et_lastname);
numberInput = findViewById(R.id.et_phone);
emailInput = findViewById(R.id.et_email);
nextBtn = findViewById(R.id.btn_next);
fnameInput.addTextChangedListener(loginTextWatcher);
lnameInput.addTextChangedListener(loginTextWatcher);
nextBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
launchNextActivity();
}
});
}
Text watcher method
private TextWatcher loginTextWatcher = new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String firstNameInput =firstNameInput.getText().toString().trim();
String lastNameInput = lastNameInput.getText().toString().trim();
// tried doing it this way
nextBtn.setEnabled(!firstNameInput.isEmpty() && !lastNameInput.isEmpty());
//What i've also tried
if(firstNameInput.length()> 0 &&
lastNameInput.length()>0){
nextBtn.setEnabled(true);
} else{
nextBtn.setEnabled(false);
}
}
#Override
public void afterTextChanged(Editable s) {
}
};
I expect the button to be disabled if one or all inputs are empty and enabled when all input fields are filled out.
create a method check all condition there like
private void checkTheConditions(){
if(condition1 && condition2)
nextBtn.setEnabled(true)
else
nextBtn.setEnabled(false)
}
call this method from afterTextChanged(Editable s) method
Let us consider this case for 2 EditTexts only as for now.
define 2 global CharSequence as below
CharSequence fName="";
CharSequence lName="";
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_profile);
fnameInput = findViewById(R.id.et_firstname);
lnameInput = findViewById(R.id.et_lastname);
numberInput = findViewById(R.id.et_phone);
emailInput = findViewById(R.id.et_email);
nextBtn = findViewById(R.id.btn_next);
fnameInput.addTextChangedListener(textWatcher);
lnameInput.addTextChangedListener(textWatcher2);
nextBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
launchNextActivity();
}
});
}
then you have to define different textwatcher for each of your Edittext
then inside each of these textWatcher assign values to CharSequence defined above
private TextWatcher textWatcher = new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
fName=s;
validate(); //method to enable or disable button (find method below)
}
#Override
public void afterTextChanged(Editable s) {
}
};
now textWatcher2
private TextWatcher textWatcher2 = new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
lName=s;
validate(); //method to enable or disable button (find method below)
}
#Override
public void afterTextChanged(Editable s) {
}
};
now write validate method
void validate(){
if (fName.length()>0 && lName.length()>0){
nextBtn.setEnabled(true);
}else {
nextBtn.setEnabled(false);
}
}
Oh! You did a small mistake. Use OR condition instead of AND. So your code should be
nextBtn.setEnabled(!firstNameInput.isEmpty() || !lastNameInput.isEmpty());
And TextWatcher will only notify when you will manually change the inputs of EditText. So TextWatcher will not wark at starting. So at first in onCreate method you should manually check those EditText feilds.
Edit:
Android new DataBinding library is best suitable for this purpose.

android on Text Change Listener

I have a situation, where there are two fields. field1 and field2. All I want
to do is empty field2 when field1 is changed and vice versa. So at the end only
one field has content on it.
field1 = (EditText)findViewById(R.id.field1);
field2 = (EditText)findViewById(R.id.field2);
field1.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
field2.setText("");
}
});
field2.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
field1.setText("");
}
});
It works fine if I attach addTextChangedListener to field1 only, but when
I do it for both fields the app crashes. Obviously because they try to change
each other indefinitely. Once field1 changes it clears field2 at this moment
field2 is changed so it will clear field1 and so on...
Can someone suggest any solution?
You can add a check to only clear when the text in the field is not empty (i.e when the length is different than 0).
field1.addTextChangedListener(new TextWatcher() {
#Override
public void afterTextChanged(Editable s) {}
#Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
if(s.length() != 0)
field2.setText("");
}
});
field2.addTextChangedListener(new TextWatcher() {
#Override
public void afterTextChanged(Editable s) {}
#Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
if(s.length() != 0)
field1.setText("");
}
});
Documentation for TextWatcher here.
Also please respect naming conventions.
In Kotlin simply use KTX extension function:
(It uses TextWatcher)
yourEditText.doOnTextChanged { text, start, count, after ->
// action which will be invoked when the text is changing
}
import core-KTX:
implementation "androidx.core:core-ktx:1.2.0"
I know this is old but someone might come across this again someday.
I had a similar problem where I would call setText on a EditText and onTextChanged would be called when I didn't want it to. My first solution was to write some code after calling setText() to undo the damage done by the listener. But that wasn't very elegant.
After doing some research and testing I discovered that using getText().clear() clears the text in much the same way as setText(""), but since it isn't setting the text the listener isn't called, so that solved my problem. I switched all my setText("") calls to getText().clear() and I didn't need the bandages anymore, so maybe that will solve your problem too.
Try this:
Field1 = (EditText)findViewById(R.id.field1);
Field2 = (EditText)findViewById(R.id.field2);
Field1.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
Field2.getText().clear();
}
});
Field2.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
Field1.getText().clear();
}
});
If you are using Kotlin for Android development then you can add TextChangedListener() using this code:
myTextField.addTextChangedListener(object : TextWatcher{
override fun afterTextChanged(s: Editable?) {}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
})
var filenameText = findViewById(R.id.filename) as EditText
filenameText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
filename = filenameText.text.toString()
Log.i("FileName: ", filename)
}
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
})
A bit late of a answer, but here is a reusable solution:
/**
* An extension of TextWatcher which stops further callbacks being called as
* a result of a change happening within the callbacks themselves.
*/
public abstract class EditableTextWatcher implements TextWatcher {
private boolean editing;
#Override
public final void beforeTextChanged(CharSequence s, int start,
int count, int after) {
if (editing)
return;
editing = true;
try {
beforeTextChange(s, start, count, after);
} finally {
editing = false;
}
}
protected abstract void beforeTextChange(CharSequence s, int start,
int count, int after);
#Override
public final void onTextChanged(CharSequence s, int start,
int before, int count) {
if (editing)
return;
editing = true;
try {
onTextChange(s, start, before, count);
} finally {
editing = false;
}
}
protected abstract void onTextChange(CharSequence s, int start,
int before, int count);
#Override
public final void afterTextChanged(Editable s) {
if (editing)
return;
editing = true;
try {
afterTextChange(s);
} finally {
editing = false;
}
}
public boolean isEditing() {
return editing;
}
protected abstract void afterTextChange(Editable s);
}
So when the above is used, any setText() calls happening within the TextWatcher will not result in the TextWatcher being called again:
/**
* A setText() call in any of the callbacks below will not result in TextWatcher being
* called again.
*/
public class MyTextWatcher extends EditableTextWatcher {
#Override
protected void beforeTextChange(CharSequence s, int start, int count, int after) {
}
#Override
protected void onTextChange(CharSequence s, int start, int before, int count) {
}
#Override
protected void afterTextChange(Editable s) {
}
}
I wrote my own extension for this, very helpful for me. (Kotlin)
You can write only like that :
editText.customAfterTextChanged { editable ->
//You have accessed the editable object.
}
My extension :
fun EditText.customAfterTextChanged(action: (Editable?)-> Unit){
this.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
override fun afterTextChanged(editable: Editable?) {
action(editable)
}
})}
I have also faced the same problem and keep on getting stackOverflow exceptions, and I come with the following solution.
edt_amnt_sent.addTextChangedListener(new TextWatcher() {
#Override
public void afterTextChanged(Editable s) {
if (skipOnChange)
return;
skipOnChange = true;
try {
//method
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
skipOnChange = false;
}
}
});
edt_amnt_receive.addTextChangedListener(new TextWatcher() {
#Override
public void afterTextChanged(Editable s) {
if (skipOnChange)
return;
skipOnChange = true;
try {
//method
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
skipOnChange = false;
}
}
});
declared initially boolean skipOnChange = false;
You can also use the hasFocus() method:
public void onTextChanged(CharSequence s, int start,
int before, int count) {
if (Field2.hasfocus()){
Field1.setText("");
}
}
Tested this for a college assignment I was working on to convert temperature scales as the user typed them in. Worked perfectly, and it's way simpler.
check String before set another EditText to empty. if Field1 is empty then why need to change again to ( "" )? so you can check the size of Your String with s.lenght() or any other solution
another way that you can check lenght of String is:
String sUsername = Field1.getText().toString();
if (!sUsername.matches(""))
{
// do your job
}
editText.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (noteid != -1) {
MainActivity.notes.set(noteid, String.valueOf(charSequence));
MainActivity.arrayAdapter.notifyDataSetChanged();
}
}
#Override
public void afterTextChanged(Editable editable) {
}
});
in this code noteid is basically arguments taken back which is being putted into the indent or passed through the indent.
Intent intent = getIntent();
noteid = intent.getIntExtra("noteid", -1);
the code on the downside is basically the extra code ,if you want to understand more clearly.
how to make the menu or insert the menu in our code ,
create the menu folder this the folder created by going into the raw
->rightclick->
directory->name the folder as you wish->
then click on the directory formed->
then click on new file and then name for file as you wish ie the folder name file
and now type the 2 lines code in it and see the magic.
new activity code named as NoteEditor.java for editing purpose,my app is basicley the note app.
package com.example.elavi.notes;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.Toast;
import static android.media.CamcorderProfile.get;
public class NoteEditorActivity extends AppCompatActivity {
EditText editText;
int noteid;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_note_editor);
editText = findViewById(R.id.editText);
Intent intent = getIntent();
noteid = intent.getIntExtra("noteid", -1);
if (noteid != -1) {
String text = MainActivity.notes.get(noteid);
editText.setText(text);
Toast.makeText(getApplicationContext(),"The arraylist content is"+MainActivity.notes.get(noteid),Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getApplicationContext(),"Here we go",Toast.LENGTH_SHORT).show();
MainActivity.notes.add("");
noteid=MainActivity.notes.size()-1;
}
editText.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (noteid != -1) {
MainActivity.notes.set(noteid, String.valueOf(charSequence));
MainActivity.arrayAdapter.notifyDataSetChanged();
}
}
#Override
public void afterTextChanged(Editable editable) {
}
});
}
}
We can remove the TextWatcher for a field just before editing its text then add it back after editing the text.
Declare Text Watchers for both field1 and field2 as separate variables to give them a name: e.g. for field1
private TextWatcher Field_1_Watcher = new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void afterTextChanged(Editable s) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
};
then add the watcher using its name:
field1.addTextChangedListener(Field_1_Watcher) for field1, and
field2.addTextChangedListener(Field_2_Watcher) for field2
Before changing the field2 text remove the TextWatcher:
field2.removeTextChangedListener(Field_2_Watcher)
change the text:
field2.setText("")
then add the TextWatcher back:
field2.addTextChangedListener(Field_2_Watcher)
Do the same for the other field
Another solution that may help someone. There are 2 EditText which change instead of each other after editing. By default, it led to cyclicity.
use variable:
Boolean uahEdited = false;
Boolean usdEdited = false;
add TextWatcher
uahEdit = findViewById(R.id.uahEdit);
usdEdit = findViewById(R.id.usdEdit);
uahEdit.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (!usdEdited) {
uahEdited = true;
}
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String tmp = uahEdit.getText().toString();
if(!tmp.isEmpty() && uahEdited) {
uah = Double.valueOf(tmp);
usd = uah / 27;
usdEdit.setText(String.valueOf(usd));
} else if (tmp.isEmpty()) {
usdEdit.getText().clear();
}
}
#Override
public void afterTextChanged(Editable s) {
uahEdited = false;
}
});
usdEdit.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (!uahEdited) {
usdEdited = true;
}
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String tmp = usdEdit.getText().toString();
if (!tmp.isEmpty() && usdEdited) {
usd = Double.valueOf(tmp);
uah = usd * 27;
uahEdit.setText(String.valueOf(uah));
} else if (tmp.isEmpty()) {
uahEdit.getText().clear();
}
}
#Override
public void afterTextChanged(Editable s) {
usdEdited = false;
}
});
Don't criticize too much. I am a novice developer
etSearch.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
TODO("Not yet implemented")
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
TODO("Not yet implemented")
}
override fun afterTextChanged(p0: Editable?) {
TODO("Not yet implemented")
}
})
you use this
I have provided latest method for textchangelistner
edMsg.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (i2 == 0){
////Edit text blanked
}
String msg = charSequence.toString();/// your text on changed in edit text
}
#Override
public void afterTextChanged(Editable editable) {
}
});
editText.addTextChangedListener(new TextWatcher()
{
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
{
}
#Override
public void onTextChanged(CharSequence chr, int i, int i1, int i2)
{
//Check char sequence is empty or not
if (chr.length() > 0)
{
//Your Code Here
}
}
#Override
public void afterTextChanged(Editable editable)
{
}
});
Add background dynamically in onCreate method:
getWindow().setBackgroundDrawableResource(R.drawable.background);
also remove background from XML.

Categories

Resources