-1
사용자가 Bluetooth 장치 이름을 설정할 수있는 메뉴 옵션이 있습니다. 현재이 대화 상자는 선택한 경우 장치의 현재 이름을 실제로 표시하지 않습니다. 편집 가능한 텍스트 필드에 사용자에게 기존 장치 이름을 표시하여 사용자가 변경하기 전에 장치의 이름을 볼 수있게하려고합니다.경고 대화 상자에 Bluetooth 장치 이름 표시
현재 방법은 다음과 같습니다.
private void changeName() {
if (D)
Log.d(TAG, "changeName");
// Open the alert dialog box
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Change Device Name");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int mButton) {
String mDevicename = input.getText().toString();
mBluetoothAdapter.setName(mDevicename);
Toast.makeText(getApplicationContext(),
"Update device name to: " + mDevicename,
Toast.LENGTH_SHORT).show();
}
});
alert.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int mButton) {
// Canceled.
}
});
alert.show();
}