Android 台灣中文網
標題: Custom View新手問題 [打印本頁]
作者: chihhao81 時間: 2013-7-19 23:39
標題: Custom View新手問題
我想寫一個APP
可以透過藍芽收資料
再把收到的資料列出、畫出
我現在可以把收到的值在activity裡的EditText顯示出來
那我要怎麼將這值傳給Custom View讓他畫出來呢?
我一開始是在Custom View那邊
直接寫 X = Activity.X
但程式一收到資料就當了
我也用過Bundle
但不知道為啥getIntent()這行都出現錯誤-.-
希望有高手可以幫忙解惑!!
作者: whl 時間: 2013-7-20 11:50
看不懂問題,貼 code 來看看。
作者: chihhao81 時間: 2013-7-20 13:55
本帖最後由 chihhao81 於 2013-7-20 14:00 編輯
這是Activity 當我藍芽收到資料的時候
case BluetoothManager.SOCKET_READ_OK:
byte[] readBuf = (byte[]) msg.obj;
String recvData = getCurrentTimString() + ":" + new String(readBuf, 0, msg.arg1);
etShow.setText( recvData + "\n" + etShow.getText().toString());
showToast("收到資料!");
//
Intent it = new Intent();
it.setClass(MainActivity.this, MyCustomView.class);
Bundle bundle = new Bundle();
bundle.putInt("data", Integer.valueOf(recvData));
it.putExtras(bundle);
startActivity(it);
break;
這邊我想把bundle裡的值取出 畫出來