在回调中改变文本框内容导致应用闪退

#6 · closed · 2 comments

View on GitHub ↗

vimcaw

e.Log 能够成功运行,但是改成设置文本框内容的话,应用一启动就闪退。 activity_main.xml ```xml <com.gcssloop.widget.RockerView android:id="@+id/rocker" android:layout_width="wrap_content" android:layout_height="wrap_content" rocker:area_background="#eee" rocker:area_radius="80dp" rocker:rocker_background="#fff" rocker:rocker_radius="30dp" tools:layout_editor_absoluteX="97dp" tools:layout_editor_absoluteY="0dp" /> ``` MainActiviuty.java ```java final TextView textView = (TextView) findViewById(R.id.textView); RockerView rocker = (RockerView) findViewById(R.id.rocker); if (null != rocker){ rocker.setListener(new RockerView.RockerListener() { @Override public void callback(int eventType, int currentAngle, float currentDistance) { switch (eventType) { case RockerView.EVENT_ACTION: // 触摸事件回调 textView.setText("angle=" + currentAngle + " - distance" + currentDistance); break; case RockerView.EVENT_CLOCK: // 定时回调 textView.setText("angle=" + currentAngle + " - distance" + currentDistance); break; } } }); } ```

Comments

GcsSloop

view只能在主线程更新,注意线程。

vimcaw

@GcsSloop 好的,谢谢