Code example for ScrollView

Methods: addView, setLayoutParams, setPadding, setView

0
	 * @return 
	 */ 
	public static Dialog prompt(Activity context, int titleId, String value,
		final Callback<String> onOk, final Callback<String> onCancel) {
		// 使用code进行布局的方法 
		ScrollView layout = new ScrollView(context);
		layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
			LayoutParams.WRAP_CONTENT));
		layout.setPadding(4, 0, 4, 0);
		final EditText editText = new EditText(context);
		if (value != null)
			editText.setText(value);
		editText.setMinLines(4);
		editText.setGravity(Gravity.TOP);
		layout.addView(editText);
 
		// 使用xml进行布局的方法 
		// LayoutInflater inflater = context.getLayoutInflater(); 
		// View layout = inflater.inflate(R.layout.prompt, 
		// (ViewGroup) context.findViewById(R.id.prompt_layout_root)); 
		// final EditText editText = (EditText) layout 
		// .findViewById(R.id.promptEditText); 
		// editText.setText(value); 
 
		Dialog dialog = new AlertDialog.Builder(context)
			.setTitle(titleId)
			.setView(layout)
			.setIcon(android.R.drawable.ic_dialog_info)
			.setPositiveButton(
				context.getResources().getString(android.R.string.yes),
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {