Back to project page android-cassowary-layout.
The source code is released under:
Apache License
If you think the Android project android-cassowary-layout listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package no.agens.cassowarylayoutdemo.util; /*ww w.ja va 2 s . c o m*/ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.EditText; import no.agens.cassowarylayoutdemo.R; /** * Created by alex on 08/12/2014. */ public class EditRatioDialog { private EditRatioDialog() { } public interface EditRatioDialogCallback { void setAspectRatioWidthFactor(float aspectRatioWidthFactor); void setAspectRatioHeightFactor(float aspectRatioHeightFactor); } public static void show(float aspectRatioWidthFactor, float aspectRatioHeightFactor, final Context context, final EditRatioDialogCallback callback) { // quick and dirty dialog to set ratio LayoutInflater li = LayoutInflater.from(context); ViewGroup dialogAspectRatioEdit = (ViewGroup)li.inflate(R.layout.dialog_aspect_ratio_edit, null); final EditText aspectRatioWidthFactorEditText = (EditText) dialogAspectRatioEdit.findViewById(R.id.aspectRatioWidthFactor); final EditText aspectRatioHeightFactorEditText = (EditText) dialogAspectRatioEdit.findViewById(R.id.aspectRatioHeightFactor); aspectRatioWidthFactorEditText.setText(Float.toString(aspectRatioWidthFactor)); aspectRatioHeightFactorEditText.setText(Float.toString(aspectRatioHeightFactor)); new AlertDialog.Builder(context) .setTitle(R.string.enter_ratio) .setView(dialogAspectRatioEdit) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { callback.setAspectRatioWidthFactor(getValueFromEditText(aspectRatioWidthFactorEditText)); callback.setAspectRatioHeightFactor(getValueFromEditText(aspectRatioHeightFactorEditText)); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); } private static float getValueFromEditText(EditText editText) { return Float.parseFloat(editText.getText().toString()); } }