For me this code works:
sendText(R.id.textToBeChanged, "changed");
Question
I am trying to change the text in a textView on the sony smartwatch control extension by a button click. However, TextView.setText()
method seems not working.
Here is my ControlExtension extended class
class SampleControlSmartWatch2 extends ControlExtension {
private static TextView textView = null;
SampleControlSmartWatch2(final String hostAppPackageName, final Context context,
Handler handler) {
//...
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.sample_control_2, null);
textView = (TextView) layout.findViewById(R.id.textToBeChanged);
}
//...
public void onObjectClick(ControlObjectClickEvent event) {
Log.i(TAG, "Before : " + textView.getText().toString()); // It shows "original"
textView.setText("changed");
Log.i(TAG, "After : " + textView.getText().toString()); // It shows "changed"
textView.invalidate(); // These two methods are added after read
textView.requestLayout(); // through several posts but it doesn't work
}
}
The logged text of textView in LogCat is shown as expected but the text in the emulator does not update. Anyone know how to solve it? Thank you.
Solution
For me this code works:
sendText(R.id.textToBeChanged, "changed");