4 using System.Collections.Generic;
10 namespace MonoDroid.Dialog
17 dialog_boolfieldright,
18 dialog_boolfieldsubleft,
19 dialog_boolfieldsubright,
24 dialog_labelfieldbelow,
25 dialog_labelfieldright,
26 dialog_onofffieldright,
30 dialog_selectlistfield,
35 dialog_textfieldbelow,
36 dialog_textfieldright,
39 public static View
LoadFloatElementLayout(Context context, View convertView, ViewGroup parent,
int layoutId, out TextView label, out SeekBar slider, out ImageView left, out ImageView right)
41 View layout = convertView ?? LoadLayout(context, parent, layoutId);
44 label = layout.FindViewById<TextView>(context.Resources.GetIdentifier(
"dialog_LabelField",
"id", context.PackageName));
45 slider = layout.FindViewById<SeekBar>(context.Resources.GetIdentifier(
"dialog_SliderField",
"id", context.PackageName));
46 left = layout.FindViewById<ImageView>(context.Resources.GetIdentifier(
"dialog_ImageLeft",
"id", context.PackageName));
47 right = layout.FindViewById<ImageView>(context.Resources.GetIdentifier(
"dialog_ImageRight",
"id", context.PackageName));
59 private static View LoadLayout(Context context, ViewGroup parent,
int layoutId)
63 LayoutInflater inflater = LayoutInflater.FromContext(context);
64 if (_resourceMap.ContainsKey((ElementLayout)layoutId))
66 string layoutName = _resourceMap[(ElementLayout)layoutId];
67 int layoutIndex = context.Resources.GetIdentifier(layoutName,
"layout", context.PackageName);
68 return inflater.Inflate(layoutIndex, parent,
false);
73 return inflater.Inflate(layoutId, parent,
false);
76 catch (InflateException ex)
78 Log.Error(
"MDD",
"Inflate failed: " + ex.Cause.Message);
82 Log.Error(
"MDD",
"LoadLayout failed: " + ex.Message);
87 public static View
LoadStringElementLayout(Context context, View convertView, ViewGroup parent,
int layoutId, out TextView label, out TextView value)
89 View layout = convertView ?? LoadLayout(context, parent, layoutId);
92 label = layout.FindViewById<TextView>(context.Resources.GetIdentifier(
"dialog_LabelField",
"id", context.PackageName));
93 value = layout.FindViewById<TextView>(context.Resources.GetIdentifier(
"dialog_ValueField",
"id", context.PackageName));
94 if(label == null || value == null)
96 layout = LoadLayout(context, parent, layoutId);
97 label = layout.FindViewById<TextView>(context.Resources.GetIdentifier(
"dialog_LabelField",
"id", context.PackageName));
98 value = layout.FindViewById<TextView>(context.Resources.GetIdentifier(
"dialog_ValueField",
"id", context.PackageName));
109 public static View
LoadButtonLayout(Context context, View convertView, ViewGroup parent,
int layoutId, out Button button)
111 View layout = LoadLayout(context, parent, layoutId);
114 button = layout.FindViewById<Button>(context.Resources.GetIdentifier(
"dialog_Button",
"id", context.PackageName));
125 View layout = convertView ?? LoadLayout(context, parent, layoutId);
128 value = layout.FindViewById<EditText>(context.Resources.GetIdentifier(
"dialog_ValueField",
"id", context.PackageName));
137 public static View
LoadBooleanElementLayout(Context context, View convertView, ViewGroup parent,
int layoutId, out TextView label, out TextView subLabel, out View value)
139 View layout = convertView ?? LoadLayout(context, parent, layoutId);
142 label = layout.FindViewById<TextView>(context.Resources.GetIdentifier(
"dialog_LabelField",
"id", context.PackageName));
143 value = layout.FindViewById<View>(context.Resources.GetIdentifier(
"dialog_BoolField",
"id", context.PackageName));
144 int id = context.Resources.GetIdentifier(
"dialog_LabelSubtextField",
"id", context.PackageName);
145 subLabel = (
id >= 0) ? layout.FindViewById<TextView>(
id): null;
156 public static View
LoadStringEntryLayout(Context context, View convertView, ViewGroup parent,
int layoutId, out TextView label, out EditText value)
158 View layout = LoadLayout(context, parent, layoutId);
161 label = layout.FindViewById<TextView>(context.Resources.GetIdentifier(
"dialog_LabelField",
"id", context.PackageName));
162 value = layout.FindViewById<EditText>(context.Resources.GetIdentifier(
"dialog_ValueField",
"id", context.PackageName));
172 private static Dictionary<ElementLayout, string> _resourceMap;
176 _resourceMap =
new Dictionary<ElementLayout, string>()
179 { ElementLayout.dialog_labelfieldbelow,
"dialog_labelfieldbelow"},
180 { ElementLayout.dialog_labelfieldright,
"dialog_labelfieldright"},
183 { ElementLayout.dialog_boolfieldleft,
"dialog_boolfieldleft"},
184 { ElementLayout.dialog_boolfieldright,
"dialog_boolfieldright"},
185 { ElementLayout.dialog_boolfieldsubleft,
"dialog_boolfieldsubleft"},
186 { ElementLayout.dialog_boolfieldsubright,
"dialog_boolfieldsubright"},
187 { ElementLayout.dialog_onofffieldright,
"dialog_onofffieldright"},
190 { ElementLayout.dialog_root,
"dialog_root"},
193 { ElementLayout.dialog_textfieldbelow,
"dialog_textfieldbelow"},
194 { ElementLayout.dialog_textfieldright,
"dialog_textfieldright"},
197 { ElementLayout.dialog_floatimage,
"dialog_floatimage"},
200 { ElementLayout.dialog_button,
"dialog_button"},
203 { ElementLayout.dialog_datefield,
"dialog_datefield"},
206 { ElementLayout.dialog_fieldsetlabel,
"dialog_fieldsetlabel"},
208 { ElementLayout.dialog_panel,
"dialog_panel"},
211 { ElementLayout.dialog_selectlist,
"dialog_selectlist"},
212 { ElementLayout.dialog_selectlistfield,
"dialog_selectlistfield"},
213 { ElementLayout.dialog_textarea,
"dialog_textarea"},
static View LoadMultilineElementLayout(Context context, View convertView, ViewGroup parent, int layoutId, out EditText value)
static View LoadStringEntryLayout(Context context, View convertView, ViewGroup parent, int layoutId, out TextView label, out EditText value)
static View LoadStringElementLayout(Context context, View convertView, ViewGroup parent, int layoutId, out TextView label, out TextView value)
static View LoadButtonLayout(Context context, View convertView, ViewGroup parent, int layoutId, out Button button)
static View LoadFloatElementLayout(Context context, View convertView, ViewGroup parent, int layoutId, out TextView label, out SeekBar slider, out ImageView left, out ImageView right)
static View LoadBooleanElementLayout(Context context, View convertView, ViewGroup parent, int layoutId, out TextView label, out TextView subLabel, out View value)