Skip to content

Instantly share code, notes, and snippets.

@prasincs
Created May 4, 2009 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prasincs/106378 to your computer and use it in GitHub Desktop.
Save prasincs/106378 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/devicename_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/alert_dialog_devicename"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/devicename_edit"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
//showing and editing AlertDialog with EditText
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
myAlertDialog = new AlertDialog.Builder(this)
.setTitle(R.string.alert_dialog_title)
.setView(textEntryView)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
EditText et = (EditText) ShowProjectsActivity.myAlertDialog.findViewById(R.id.devicename_edit);
deviceName = et.getText().toString();
Log.i(TAG, deviceName);
if (comm.registerDevice(appKey, imei, deviceName)){
Utils.showToast(ShowProjectsActivity.this, R.string.device_registered);
}else {
Utils.showToast(ShowProjectsActivity.this, R.string.device__not_registered);
}
ShowProjectsActivity.this.finish();
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do nothing*/
}
}).create();
myAlertDialog.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment