我想把主活動接收到的資料實時地顯示在alertdialog上,點擊alertdialog中自定義的按鈕能夠呼叫主活動中的發送資料的方法,但是實際除錯發現按鈕不回應,資料也不顯示,請問如何解決?
alertDialog=new AlertDialog.Builder(SecondActivity.this)
.setView(R.layout.dialog_window)
.create();
LayoutInflater inflater = LayoutInflater.from(SecondActivity.this);
View dialogView=inflater.inflate(R.layout.dialog_window, null);
Button sendMessage = (Button)dialogView.findViewById(R.id.sendMessage);
EditText editText=(EditText) dialogView.findViewById(R.id.editText);
responseData=https://bbs.csdn.net/topics/(TextView) dialogView.findViewById(R.id.response_data);
sendMessage.setOnClickListener(view -> {
if(alertDialog!=null && alertDialog.isShowing()) {
Log.e("alertdialog", "onCreate: ");
String message = editText.getText().toString();
if (!message.equals("")) {
byte[] byteMessage = message.getBytes();
writeBytes(byteMessage);
}
}
});
alertDialog.show();
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/268880.html
標籤:Java相關
上一篇:STS下,創建一個 Spring Starter Project 出現錯誤,大神幫忙看下謝謝
下一篇:求教使用rocketmq4.5例外NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuff
