문제

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.

도움이 되었습니까?

해결책

For me this code works:

sendText(R.id.textToBeChanged, "changed");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top