I have the following problem:
I want to use the text of a TextView
which is changing every 10 seconds. With a Button
, I want to use the text of the TextView
and show it in another TextView
.
I tried it with the following code.
buttonSave.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
buttonSave.setClickable(false);
buttonSave.setVisibility(View.GONE);
if(buttonSave.isEnabled()) {
String copy = textView.getText().toString();
settingsview.append("\n" + copy);
}
buttonSave.setEnabled(false);
}
My problem now is that it works fine until the TextView
refreshes and then the TextView
is clearing everything without pressing the button. This is the code which changes my textfild. The toCheck StringBuilder is a input of OCR which is refreshing every 10secs
public void filterit(StringBuilder toCheck){
Pattern patternDate = Pattern.compile("\\d{2}\\.\\d{2}\\.\\d{4}");
Matcher matcher = patternDate.matcher(toCheck.toString());
while (matcher.find()) {
//textView.setText(matcher.group());
settingsview.setText(matcher.group());
}
}
try this way
buttonSave.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
if(buttonSave.isEnabled()) {
String copy = textView.getText().toString();
ettingsview.setText(settingsview.getText().toString()+"\n" + copy);
buttonSave.setClickable(false);
buttonSave.setVisibility(View.GONE);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.