Code example for Dialog

Methods: getWindow, setContentView, show

0
		ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 0);
		layout.setLayoutParams(layoutParams);
		layout.addView(textView);
		layout.setOnTouchListener(this);
 
		dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
		dialog.setContentView(layout);
		return dialog;
	} 
 
	public static TextView createView (Context context) {
		final TextView view = new TextView(context) {
			Editable editable = new PassThroughEditable();
 
			@Override 
			protected boolean getDefaultEditable () { 
				return true; 
			} 
 
			@Override 
			public Editable getEditableText () {
				return editable;
			} 
 
			@Override 
			protected MovementMethod getDefaultMovementMethod () {
				return ArrowKeyMovementMethod.getInstance();
			} 
 
			@Override 
			public boolean onKeyDown (int keyCode, KeyEvent event) {
				Log.d("Test", "down keycode: " + event.getKeyCode());
				return super.onKeyDown(keyCode, event);
			} 
 
			@Override 
			public boolean onKeyUp (int keyCode, KeyEvent event) {
				Log.d("Test", "up keycode: " + event.getKeyCode());
				return super.onKeyUp(keyCode, event);
			} 
		}; 
// view.setCursorVisible(false); 
		return view;
	} 
 
	public void setVisible (boolean visible) {
		if (visible && dialog != null) {
			dialog.dismiss();
			dialog = null;
		} 
		if (visible && dialog == null && !input.isPeripheralAvailable(Peripheral.HardwareKeyboard)) {
			handler.post(new Runnable() {
				@Override 
				public void run () { 
					dialog = createDialog();
					dialog.show();
 
					handler.post(new Runnable() {
						@Override 
						public void run () { 
							dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
							InputMethodManager input = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
							if (input != null) input.showSoftInput(textView, InputMethodManager.SHOW_FORCED);
						} 
					}); 
 
					final View content = dialog.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
					content.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
						int[] screenloc = new int[2];
						private int keyboardHeight;
						private boolean keyboardShowing;