I'm developing an android application using eclipse. I have a listview and each row of this contains an EditText. When I click on an EditText I want two things to do.
1: Reload all the EditText with texts from my data array.
2: Set the text of the clicked EditText to a constant string(say "0").
For this I used the below onclicklisetner for EditText.
myEdittext.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
adapter.notifyDataSetChanged();//adapter is my arrayadapter of the listview
EditText clickedText = (EditText)v;
clickedText.setText("0");
}
});
As you can see I'm using 'notifyDataSetChanged' method to reload the EditTexts in the listview and 'setText' method to set the clicked EditText's text to "0".
But the 'setText' method is not working. If I comment the line 'adapter.notifyDataSetChanged()' the 'setText' method is working.
I also tried to do this by calling the setText method after a delay(to check if the notifyDataSetChanged is starting a new thread) but failed.
How can I make both the methods to work in my onClick method.
Thanks in Advance.