안드로이드 개발 질문/답변
(글 수 45,052)
public class Mainsend extends Activity {
private ListView mConversationView;
private EditText mOutEditText;
private BluetoothChatService mChatService = null;
.
.
.
}
private void setupChat() {
mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
mConversationView = (ListView) findViewById(R.id.in);
mConversationView.setAdapter(mConversationArrayAdapter);
// Initialize the compose field with a listener for the return key
mOutEditText = (EditText) findViewById(R.id.edit_text_out);
mOutEditText.setOnEditorActionListener(mWriteListener);
Button = (ToggleButton) findViewById(R.id.button);
TButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
sendMessage(turnonMSG);
}
}
}
});
.
.
.
private void sendMessage(String message) {
// Check that we're actually connected before trying anything
if (mChatService.getState() != BluetoothChatService.STATE_CONNECTED) {
Toast.makeText(this, R.string.not_connected, Toast.LENGTH_SHORT).show();
return;
}
// Check that there's actually something to send
if (message.length() > 0) {
// Get the message bytes and tell the BluetoothChatService to write
byte[] send = message.getBytes();
mChatService.write(send);
// Reset out string buffer to zero and clear the edit text field
mOutStringBuffer.setLength(0);
mOutEditText.setText(mOutStringBuffer);
}
}
---------------------------------------------------------------------------
public class MyView2 extends View {
.
.
.
.
@Override
protected void onDraw(Canvas canvas) {
if(xy > 1){ // xy 좌표가 1보다 크면
}
}
어플에서 그림을 그려서 일정 값이 넘어서면 값을 블루투스로 넘겨주는것을 하고 있는데
며칠동안 제가 아는 갖은 수를 다 해써봤는데 안되네요...
메인에서 변수값을 받아서 처리해볼려다가 역시나 안되고...
메인 setupChat() 안에서의 버튼동작은 잘됩니다. 어떻게 해야 다른 클래스에서 실행이 가능할까요?
좀 더 보기 좋게 적어주시면 좋을 것 같네요.
class는 Main과 Sub로 나뉘고
Sub에서 Main 클래스 안의 함수를 실행하고 싶으신건가요?
맞다면
와 같이 하는걸 말하시는게 맞나요?