protected override void OnCreate (Android.OS.Bundle savedInstanceState) { base.OnCreate (savedInstanceState); var mActionBar = ActionBar; mActionBar.SetDisplayHomeAsUpEnabled(true); mActionBar.SetDisplayShowCustomEnabled(true); mActionBar.SetIcon(new ColorDrawable(Resources.GetColor(Android.Resource.Color.Transparent))); mActionBar.SetDisplayShowTitleEnabled(false); LayoutInflater mInflater = LayoutInflater.From(this); View mCustomView = mInflater.Inflate(Resource.Layout.samplelist_layout, null); selectedGroup= (Group)MainActivity.SelectedIntent.GetSerializableExtra("sample"); SampleLayout sampleLayouts= new SampleLayout(MainActivity.context,selectedGroup.samples); mActionBar.CustomView = mCustomView; Sample selectedSample=(Sample)selectedGroup.samples[selectedIndex]; SetContentView(Resource.Layout.SamplePage); ImageView imageButton = (ImageView) mCustomView .FindViewById(Resource.Id.imageButton); Context wrapper = new ContextThemeWrapper(this, Android.Resource.Style.Theme); ListPopupWindow popupWindow = new ListPopupWindow(wrapper); popupWindow.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.listpopup)); imageButton.Click += (object sender, EventArgs e) => { popupWindow.Show(); }; popupWindow.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { Sample subSamples = (Sample) selectedGroup.samples[e.Position]; selectedIndex = e.Position; RefreshSample(subSamples); popupWindow.Dismiss(); }; RelativeLayout settingButton = (RelativeLayout) mCustomView .FindViewById(Resource.Id.settingsParent); settingButton.Click += (object sender, EventArgs e) => { onProperyWindowClick(); }; if(selectedGroup.samples.Count<=1) { imageButton.Visibility = ViewStates.Invisible; } popupWindow.AnchorView = imageButton; popupWindow.Width = measureContentWidth(sampleLayouts); popupWindow.SetAdapter(sampleLayouts); RefreshSample (selectedSample); }
void ParseXML() { XmlReader xtr =Resources.GetXml (Resource.Xml.samplelist); xtr.Read(); while (!xtr.EOF) { List<SampleBase> groups = new List<SampleBase> (); xtr.Read (); if (xtr.Name == "Samples" && !xtr.IsStartElement()) break; bool isGroup = false; while (!isGroup) { if (xtr.Name == "Group" && xtr.IsStartElement ()) { Group group = new Group (); SetSample (group, xtr); xtr.Read (); List<SampleBase> samples = new List<SampleBase>(); bool isSample = false; while (!isSample) { if (xtr.Name == "Sample" && xtr.IsStartElement ()) { Sample tc = new Sample (); SetSample (tc, xtr); samples.Add (tc); xtr.Read (); xtr.Read (); if (xtr.Name == "Group" && !xtr.IsStartElement ()) { isSample = true; xtr.Read (); group.samples = samples; groups.Add (group); } } else if (xtr.Name == "Group" && !xtr.IsStartElement ()) { isSample = true; xtr.Read (); groups.Add (group); } } if (xtr.Name == "Samples" && !xtr.IsStartElement()) { isGroup = true; xtr.Read(); } } } xtr.Read(); this.aSamples = groups; } xtr.Close(); }
public void MoveToSample(Group sample) { SampleActivity.selectedIndex=0; if(SelectedIntent==null) SelectedIntent = new Intent(this, typeof(SampleActivity)); SelectedIntent.PutExtra("sample", sample); StartActivity(SelectedIntent); OverridePendingTransition(Resource.Animation.slideright,Resource.Animation.slide2); base.Finish (); }