我在使用Android应用程序时遇到问题,它在不同线程上的Socket上监听,并且收到消息后,它分解为String.split,其中一部分字符串应该是Activtity标题,但从未更新。该怎么解决?
activity.runOnUiThread(()-> getSupportActionBar()。setTitle(components [1])); activity.runOnUiThread(()-> setTitle(components [1]));
class updateUIThread实现Runnable { public String msg;
public updateUIThread(String str){
this.msg = str;
}
public void run(){
String components[] = msg.split(":");
supervisorMessage.setText(String.valueOf(components[2]));
activity.runOnUiThread(() -> getSupportActionBar().setTitle(components[1]));
activity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#" + components[0])));
}
}