コード例 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate {
                button.Text = string.Format("{0} clicks!", count++);

                Intent i = new Intent(this, typeof(Activity1));

                i.PutExtra("name", "test");
                i.PutExtra("name1", "test");

                Object ii ="d";
                ClassSer cs = new ClassSer()
                {
                    Name = "s",
                };
               // i.PutExtra("ClassSer", cs);
                StartActivity(i);
            };

            ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1);
            adapter.Add("1");
            adapter.Add("12");

            ListView lv = FindViewById<ListView>(Resource.Id.listView1);
            lv.Adapter = adapter;
        }
コード例 #2
0
        private void SetConfigurationSpin()
        {
            int          index = 0, i = 0;
            ArrayAdapter adapter = new ArrayAdapter(Application.Context, Android.Resource.Layout.SimpleSpinnerItem);

            try
            {
                if ((CSISystemContext.ConfigurationList == null) || (CSISystemContext.ConfigurationList.Count <= 0))
                {
                    adapter.Add(string.Empty);
                }
                else
                {
                    foreach (string config in CSISystemContext.ConfigurationList)
                    {
                        adapter.Add(config);
                        if (CSISystemContext.Configuration == config)
                        {
                            index = i;
                        }
                        i += 1;
                    }
                }
                adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                ConfigurationSpinner.Adapter = adapter;
                ConfigurationSpinner.SetSelection(index);
            }
            catch (Exception Ex)
            {
                WriteErrorLog(Ex);
                ConfigurationSpinner.Adapter = adapter;
                ConfigurationSpinner.SetSelection(index);
            }
        }
コード例 #3
0
ファイル: MainActivity.cs プロジェクト: littlefeihu/checktask
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            Assembly asm       = Assembly.GetExecutingAssembly();
            Stream   pdfStream = asm.GetManifestResourceStream("PDFToImage.xfinium.pdf");

            document = new PdfFixedDocument(pdfStream);
            pdfStream.Close();

            Spinner pageNumbers           = FindViewById <Spinner>(Resource.Id.pageNumberSpinner);
            ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);

            pageNumbers.Adapter = adapter;
            adapter.Add("Please select a page number");
            for (int i = 1; i <= document.Pages.Count; i++)
            {
                adapter.Add(i.ToString());
            }
            Button button = FindViewById <Button> (Resource.Id.btnConvertToImage);

            button.Click += delegate {
                if ((pageNumbers.SelectedItemPosition >= 1) && (pageNumbers.SelectedItemPosition <= document.Pages.Count))
                {
                    PdfPageRenderer renderer  = new PdfPageRenderer(document.Pages [pageNumbers.SelectedItemPosition - 1]);
                    Bitmap          pageImage = renderer.ConvertPageToImage(96);

                    ImageView pageImageView = FindViewById <ImageView> (Resource.Id.pageImageView);
                    pageImageView.SetImageBitmap(pageImage);
                }
            };
        }
コード例 #4
0
        private void SeThemeSpin()
        {
            ArrayAdapter adapter = new ArrayAdapter(Application.Context, Android.Resource.Layout.SimpleSpinnerItem);

            try
            {
                adapter.Add(GetString(Resource.String.LightTheme));
                adapter.Add(GetString(Resource.String.DarkTheme));
                adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerItem);
                ThemeSpinner.Adapter = adapter;
                if (CSISystemContext.Theme == InterpretThemeValue(GetString(Resource.String.LightTheme)))
                {
                    ThemeSpinner.SetSelection(0);
                }
                else
                {
                    ThemeSpinner.SetSelection(1);
                }
            }
            catch (Exception Ex)
            {
                WriteErrorLog(Ex);
                ThemeSpinner.Adapter = adapter;
                ThemeSpinner.SetSelection(0);
            }
        }
コード例 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            this.SetContentView(Resource.Layout.winSelection);
            base.OnCreate(savedInstanceState);
            this.spnTime   = FindViewById <Spinner> (Resource.Id.spnTime);
            this.spnCourse = FindViewById <Spinner> (Resource.Id.spnCourse);

            //Service Calls

            //Time Spinner
            this.spnTime.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spnTimeSelected);
            this.timeAdapter           = ArrayAdapter.CreateFromResource(this, Resource.Array.timeSpinner, Android.Resource.Layout.SimpleSpinnerItem);
            this.timeAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerItem);
            this.spnTime.Adapter = timeAdapter;


            //CourseSpinner
            this.spnCourse.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spnCourseSelected);
            this.courseAdapter           = new ArrayAdapter <string> (this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            this.spnCourse.Adapter       = courseAdapter;

            //Add modules to array adapter.
            courseAdapter.Add("course 1");
            courseAdapter.Add("course 2");


            // Create your application here
        }
コード例 #6
0
        //event for when the category dropdown changes
        private void Category_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            Spinner spinner = (Spinner)sender;

            //if the selection contains the text "transfer" clear the type_toaccount dropdown and load it with all accounts besides the current account
            if (spinner.GetItemAtPosition(e.Position).ToString().Contains("Transfer"))
            {
                transactionTypeToAccountAdapter.Clear();
                foreach (Account act in MainActivity.accounts)
                {
                    if (act.PK != accountPK)
                    {
                        transactionTypeToAccountAdapter.Add(act.Name);
                    }
                }
                defaultTypeToAccountLoaded = false;
            }
            //if the selection is anything else besides transfer clear and load the tyep_toaccount dropdown back to default
            else
            {
                if (defaultTypeToAccountLoaded == false)
                {
                    transactionTypeToAccountAdapter.Clear();
                    transactionTypeToAccountAdapter.Add("Withdrawal");
                    transactionTypeToAccountAdapter.Add("Deposit");
                    defaultTypeToAccountLoaded = true;
                }
            }
        }
コード例 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AddPhone);

            Spinner  phoneType      = FindViewById <Spinner>(Resource.Id.spinnerPhoneType);
            EditText phoneNumber    = FindViewById <EditText>(Resource.Id.editTextPhoneNumber);
            Button   btnCreatePhone = FindViewById <Button>(Resource.Id.btnCreatePhone);

            ArrayAdapter phoneTypes = new ArrayAdapter(this, Resource.Layout.TextViewItem);

            phoneTypes.Add("Home");
            phoneTypes.Add("Mobile");
            phoneTypes.Add("Fax");

            phoneType.Adapter = phoneTypes;

            if (ViewContactActivity.SelectedPhone != null)
            {
                phoneNumber.Text = ViewContactActivity.SelectedPhone.Number;
                switch (ViewContactActivity.SelectedPhone.Type)
                {
                case "Home": phoneType.SetSelection(0); break;

                case "Mobile": phoneType.SetSelection(1);  break;

                case "Fax": phoneType.SetSelection(2); break;
                }
                btnCreatePhone.Text = "Update";
                p.ID = ViewContactActivity.SelectedPhone.ID;
            }

            btnCreatePhone.Click += BtnCreatePhone_Click;
        }
コード例 #8
0
        private void Search_Click(object sender, EventArgs e)
        {
            adapter.Clear();
            lstsearch.Visibility = ViewStates.Visible;
            try
            {
                if (edtsearch.Text.Length > 0)
                {
                    string response = new WebClient().DownloadString("http://www.planmytrip.net23.net/search.php?ds=" + edtsearch.Text.Trim());
                    try {
                        WebClient client   = new WebClient();
                        Stream    stream   = client.OpenRead("http://www.planmytrip.net23.net/DATA/search.pmt");
                        int       counting = 0;
                        String    content  = "";
                        if (stream != null)
                        {
                            StreamReader reader = new StreamReader(stream);
                            while (!reader.EndOfStream)
                            {
                                content = reader.ReadLine();
                                adapter.Add(content);
                                adapter.NotifyDataSetChanged();
                                counting++;
                            }
                            reader.Close();
                        }
                        stream.Close();

                        if (counting == 0)
                        {
                            adapter.Add("Destination does not exist");
                        }
                        else if (counting > 1)
                        {
                            adapter.Add("Please search exact destination");
                        }
                        if (adapter.Count > 0)
                        {
                            lstsearch.Adapter = adapter;
                        }
                        if (counting == 1 && content != "")
                        {
                            var intent = new Intent(this, typeof(userdataActivity));
                            intent.PutExtra("text", content);
                            StartActivity(intent);
                        }
                    }
                    catch (Exception) {
                        Android.Widget.Toast.MakeText(this, "Error: Cannot find destination file", ToastLength.Short).Show();
                    }
                }
                else
                {
                    Android.Widget.Toast.MakeText(this, "Error: Please fill the field", ToastLength.Short).Show();
                }
            }
            catch (Exception) {
                Android.Widget.Toast.MakeText(this, "Error: Server down", ToastLength.Short).Show();
            }
        }
コード例 #9
0
        /// <param name="requestCode">The integer request code originally supplied to
        ///  startActivityForResult(), allowing you to identify who this
        ///  result came from.</param>
        /// <param name="resultCode">The integer result code returned by the child activity
        ///  through its setResult().</param>
        /// <param name="data">An Intent, which can return result data to the caller
        ///  (various data can be attached to Intent "extras").</param>
        /// <summary>
        /// Called when an activity you launched exits, giving you the requestCode
        ///  you started it with, the resultCode it returned, and any additional
        ///  data from it.
        /// </summary>
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            switch (requestCode)
            {
            case (int)EnActivityResultCode.VISIBILITY_REQUEST:
                // When the request to enable Bluetooth returns
                if (resultCode == Result.FirstUser)
                {
                    // Bluetooth is now enabled, so set up a chat session
                    List <string> address = BTManager.Instance.GetPaired();
                    foreach (string addr in address)
                    {
                        _pairedArrayList.Add(BTManager.Instance.getRemoteDevice(addr).Name + "\n" + addr);
                    }

                    if (!_start)
                    {
                        SetTitle(Resource.String.scanning);
                        _newArrayList.Clear();
                        BTManager.Instance.Discovery();
                    }
                    if (_connecting)
                    {
                        connection();
                    }
                }
                else if (resultCode == Result.Canceled)
                {
                    BTManager.Instance.DisableBluetooth();
                }
                break;
            }
        }
コード例 #10
0
ファイル: MainActivity.cs プロジェクト: baitun/BGUEP-Journal
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            Assembly asm = Assembly.GetExecutingAssembly();
            Stream pdfStream = asm.GetManifestResourceStream("PDFToImage.xfinium.pdf");
            document = new PdfFixedDocument (pdfStream);
            pdfStream.Close();

            Spinner pageNumbers = FindViewById<Spinner>(Resource.Id.pageNumberSpinner);
            ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            pageNumbers.Adapter = adapter;
            adapter.Add("Please select a page number");
            for (int i = 1; i <= document.Pages.Count; i++)
            {
                adapter.Add(i.ToString());
            }
            Button button = FindViewById<Button> (Resource.Id.btnConvertToImage);

            button.Click += delegate {
                if ((pageNumbers.SelectedItemPosition >= 1) && (pageNumbers.SelectedItemPosition <= document.Pages.Count))
                {
                    PdfPageRenderer renderer = new PdfPageRenderer (document.Pages [pageNumbers.SelectedItemPosition - 1]);
                    Bitmap pageImage = renderer.ConvertPageToImage (96);

                    ImageView pageImageView = FindViewById<ImageView> (Resource.Id.pageImageView);
                    pageImageView.SetImageBitmap(pageImage);
                }
            };
        }
コード例 #11
0
        public void OnScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
        {
            System.Diagnostics.Debug.WriteLine(firstVisibleItem);
            if (firstVisibleItem + visibleItemCount == totalItemCount)               // Clear items, add from current half way to chunk size after last item, scroll back to old last item
            {
                var firstItem = adapter.GetItem(chunksize);
                adapter.Clear();
                for (int i = 0; i < chunksize * 2; i++)
                {
                    adapter.Add(firstItem.AddDays(i));
                }
                adapter.NotifyDataSetChanged();
                view.SetSelection(chunksize - visibleItemCount - 1);
            }
            else if (firstVisibleItem == 0)                     // Clear items, add from chunk size before first item, scroll back to old first item

            {
                var lastItem = adapter.GetItem(chunksize);
                adapter.Clear();
                for (int i = chunksize * 2 - 1; i >= 0; i--)
                {
                    adapter.Add(lastItem.AddDays(-i));
                }
                adapter.NotifyDataSetChanged();
                view.SetSelection(chunksize - 1);
            }
        }
コード例 #12
0
 private void SNetClient_OnDisconnect(object o, SocketEventArgs e)
 {
     Application.SynchronizationContext.Post((c) =>
     {
         _adapter.Add("Disconnected from server!");
         _adapter.NotifyDataSetChanged();
     }, this);
 }
コード例 #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetTheme(Resource.Style.Theme_Normal);

            SetContentView(Resource.Layout.Ingest);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            Window.ClearFlags(WindowManagerFlags.TranslucentStatus);

            if (savedInstanceState == null)
            {
                var fragmentTransaction = SupportFragmentManager.BeginTransaction();
                allclipsfragment = new AllClipsFragment(AllClipsFragment.ClipViewMode.INGEST);
                fragmentTransaction.Replace(Resource.Id.selector, allclipsfragment, "frag1");
                fragmentTransaction.Commit();
                (allclipsfragment as IImagePausable).Pause();
                allclipsfragment.OnPreview += Allclipsfragment_OnPreview;
                allclipsfragment.OnBack    += Allclipsfragment_OnBack;
                allclipsfragment.OnNext    += Allclipsfragment_OnNext;
            }
            else
            {
                allclipsfragment = SupportFragmentManager.FindFragmentByTag("frag1") as AllClipsFragment;
            }



            IngestWizard.ShowWizard(this, false);

            spinner = FindViewById <Spinner>(Resource.Id.filter_spinner);

            filters = new IconSpinnerAdapter(this);
            foreach (var t in Bootlegger.MediaItemFilter)
            {
                filters.Add(new FilterTuple <Bootlegger.MediaItemFilterType, string>(t.Key, t.Value));
            }

            spinner.Adapter = filters;

            spinner2 = FindViewById <Spinner>(Resource.Id.direction_spinner);

            directions = new IconOrderSpinnerAdapter(this);
            directions.Add(new FilterTuple <Bootlegger.MediaItemFilterDirection, string>(Bootlegger.MediaItemFilterDirection.ASCENDING, ""));
            directions.Add(new FilterTuple <Bootlegger.MediaItemFilterDirection, string>(Bootlegger.MediaItemFilterDirection.DESCENDING, ""));

            spinner2.Adapter = directions;


            spinner.ItemSelected  += Spinner_ItemSelected;
            spinner2.ItemSelected += Spinner2_ItemSelected;
        }
コード例 #14
0
        private void OnColumnSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            Spinner newSpinner = (Spinner)sender;

            viewModel.SelectedColumn = newSpinner.GetItemAtPosition(e.Position).ToString();

            if (viewModel.SelectedColumn == "All Columns")
            {
                conditionDropdown.Visibility = ViewStates.Gone;
                conditionTextView.Visibility = ViewStates.Gone;
            }
            else
            {
                conditionDropdown.Visibility = ViewStates.Visible;
                conditionTextView.Visibility = ViewStates.Visible;
                foreach (var prop in typeof(BookInfo).GetProperties())
                {
                    if (prop.Name == viewModel.SelectedColumn)
                    {
                        var type = prop.GetType();
                        if (prop.PropertyType == typeof(Java.Lang.String))
                        {
                            condtionAdapter.Clear();
                            condtionAdapter.Add("Equals");
                            condtionAdapter.Add("Contains");
                            if (this.viewModel.SelectedCondition == "Equals")
                            {
                                this.viewModel.SelectedCondition = "Equals";
                            }
                            else
                            {
                                this.viewModel.SelectedCondition = "Contains";
                            }
                        }
                        else
                        {
                            condtionAdapter.Clear();
                            condtionAdapter.Add("Equals");
                            condtionAdapter.Add("NotEquals");
                            if (this.viewModel.SelectedCondition == "Equals")
                            {
                                this.viewModel.SelectedCondition = "Equals";
                            }
                            else
                            {
                                this.viewModel.SelectedCondition = "NotEquals";
                            }
                        }
                    }
                }
            }
            if (filterText.Query != "")
            {
                this.OnFilterChanged();
            }
        }
コード例 #15
0
        private void SetDetailList()
        {
            ArrayAdapter adapter = new ArrayAdapter(Application.Context, Android.Resource.Layout.SimpleGalleryItem);

            adapter.Add(string.Format("{0}: {1}", Application.Context.GetString(Resource.String.Site), CSISystemContext.Site));
            adapter.Add(string.Format("{0}: {1}", Application.Context.GetString(Resource.String.Warehouse), CSISystemContext.DefaultWarehouse));
            adapter.Add(string.Format("{0}: {1}", Application.Context.GetString(Resource.String.Device), CSISystemContext.GetDeviceId()));
            adapter.Add(string.Format("{0}: {1}", Application.Context.GetString(Resource.String.RegisterLicense), Application.Context.GetString(Resource.String.NoLicensed)));
            adapter.Add(string.Format("{0}: {1}", Application.Context.GetString(Resource.String.ExpirationDate), CSISystemContext.ExpDate));
            ListView.Adapter = adapter;
        }
コード例 #16
0
        private void FillSettings()
        {
            //Reset to default
            items.Clear();
            ChurchDetails.Clear();
            ChurchNames = new ArrayAdapter <string>(Main, Android.Resource.Layout.SimpleListItem1, items);
            ChurchNames.Add(_church.Name);
            ChurchDetails.Add(_church);
            _index = 0;

            //This loops through the list and writes out the title and URL.
            for (int i = 0; i < xml.Count; i++)
            {
                ChurchItems ci = new ChurchItems();
                foreach (XmlNode xl in xml[i])
                {
                    string name = xl.Attributes.GetNamedItem("name").InnerText;
                    switch (name)
                    {
                    case "Title":
                        ci.Title = xl.InnerText;
                        break;

                    case "Name":
                        ci.Name = xl.InnerText;
                        break;

                    case "Feed":
                        ci.Feed = xl.InnerText;
                        break;

                    case "Website":
                        ci.Website = xl.InnerText;
                        break;

                    case "IconUrl":
                        ci.IconUrl = xl.InnerText;
                        break;

                    case "BackgroundUrl":
                        ci.BackgroundUrl = xl.InnerText;
                        break;

                    default:
                        Log.Debug(LoadRSS.AppName, name + " not found, check your spelling!");
                        break;
                    }
                }
                //we have the values add them
                ChurchDetails.Add(ci);
                ChurchNames.Add(ci.Name);
            }
            _index = ChurchDetails.Count;
        }
コード例 #17
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            try {
                // Setup the window
                RequestWindowFeature(WindowFeatures.IndeterminateProgress);
                SetContentView(Resource.Layout.device_list);

                // Set result CANCELED incase the user backs out
                SetResult(Result.Canceled);

                // Initialize array adapters. One for already paired devices and
                // one for newly discovered devices
                pairedDevicesArrayAdapter = new ArrayAdapter <string>(this, Resource.Layout.device_name);
                newDevicesArrayAdapter    = new ArrayAdapter <string>(this, Resource.Layout.device_name);

                // Find and set up the ListView for paired devices
                var pairedListView = FindViewById <ListView>(Resource.Id.paired_devices);
                pairedListView.Adapter    = pairedDevicesArrayAdapter;
                pairedListView.ItemClick += DeviceListClick;

                // Find and set up the ListView for newly discovered devices
                var newDevicesListView = FindViewById <ListView>(Resource.Id.new_devices);
                newDevicesListView.Adapter    = newDevicesArrayAdapter;
                newDevicesListView.ItemClick += DeviceListClick;

                var filter = new IntentFilter(BluetoothDevice.ActionFound);

                // Register for broadcasts when discovery has finished
                filter = new IntentFilter(BluetoothAdapter.ActionDiscoveryFinished);

                // Get the local Bluetooth adapter
                btAdapter = BluetoothAdapter.DefaultAdapter;

                // Get a set of currently paired devices
                var pairedDevices = btAdapter.BondedDevices;

                // If there are paired devices, add each one to the ArrayAdapter
                if (pairedDevices.Count > 0)
                {
                    FindViewById <View>(Resource.Id.title_paired_devices).Visibility = ViewStates.Visible;
                    foreach (var device in pairedDevices)
                    {
                        pairedDevicesArrayAdapter.Add(device.Name + "\n" + device.Address);
                    }
                }
                pairedDevicesArrayAdapter.Add("Bluetooth settings");
                pairedDevicesArrayAdapter.Add("Cancel");
            }
            catch (Exception e) { Console.WriteLine(e.ToString()); Finish(); }
        }
コード例 #18
0
ファイル: ChangeState.cs プロジェクト: FlyingPie/SteamDroid
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            stateAdapter = new ArrayAdapter<EPersonaState>(this, Android.Resource.Layout.SimpleListItem1);
            stateAdapter.Add(EPersonaState.Online);
            stateAdapter.Add(EPersonaState.Away);
            stateAdapter.Add(EPersonaState.Busy);
            stateAdapter.Add(EPersonaState.Snooze);
            stateAdapter.Add(EPersonaState.Offline);

            ListAdapter = stateAdapter;
        }
コード例 #19
0
ファイル: ChangeState.cs プロジェクト: flyingpie/SteamDroid
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            stateAdapter = new ArrayAdapter <EPersonaState>(this, Android.Resource.Layout.SimpleListItem1);
            stateAdapter.Add(EPersonaState.Online);
            stateAdapter.Add(EPersonaState.Away);
            stateAdapter.Add(EPersonaState.Busy);
            stateAdapter.Add(EPersonaState.Snooze);
            stateAdapter.Add(EPersonaState.Offline);

            ListAdapter = stateAdapter;
        }
コード例 #20
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Settings);

            //fav class selector
            Spinner classSpinner          = FindViewById <Spinner>(Resource.Id.favouriteTimetable);
            ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);

            classSpinner.Adapter = adapter;

            if (StaticWebUntis.Classes != null)
            {
                adapter.AddAll(new List <string>(StaticWebUntis.Classes.Select(u => u.name)));
            }
            else
            {
                Toast.MakeText(this, "Error: Could not load classes!", ToastLength.Long).Show();
            }


            //timetable on startup selector
            Spinner optionSpinner = FindViewById <Spinner>(Resource.Id.startingTimetable);
            ArrayAdapter <string> optionAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);

            optionSpinner.Adapter = optionAdapter;

            optionAdapter.Add("Startstundenplan");
            optionAdapter.Add("Lieblingsstundenplan");
            optionAdapter.Add("Zuletzt angesehener");

            //logout button - calls Logout on Click
            Button logout = FindViewById <Button>(Resource.Id.logoutButton);

            logout.Click += Logout_Click;

            //logout button - calls Logout on Click
            TextView alarm = FindViewById <TextView>(Resource.Id.alarmTextView);

            alarm.Click += delegate {
                StartActivity(typeof(AlarmActivity));
            };

            //The switch to turn notifications on or off
            Switch notifier = FindViewById <Switch>(Resource.Id.changeInTimetableSwitch);

            notifier.CheckedChange += Notifier_CheckedChange;

            _dataman = new DataManager(this);
        }
コード例 #21
0
        void spinner_Itemselected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            _play.Clear();
            if (_players.Count > 0)
            {
                _play.Add("Player");
                _play.Add("Played");
                _play.Add("Points");

                //string [][] values = new string[players.Count] [];

                PointsInfo [] values = new PointsInfo[_players.Count];

                int i = 0;

                foreach (string name in _players)
                {
                    values [i] = new PointsInfo(name, Archive.Instance.GetPlayed(name), Archive.Instance.GetTotalAward(name));
                    ++i;
                }

                switch (e.Id)
                {
                case 0:
                    SortByPointDescend(values, _players.Count);
                    break;

                case 1:
                    SortByPointAscend(values, _players.Count);
                    break;

                case 2:
                    SortByPlayedDescend(values, _players.Count);
                    break;

                case 3:
                    SortByPlayedAscend(values, _players.Count);
                    break;

                case 4:
                    SortByNameDescend(values, 0, _players.Count - 1);
                    break;

                case 5:
                    SortByNameAscend(values, 0, _players.Count - 1);
                    break;
                }
                for (int j = 0; j < _players.Count; j++)
                {
                    PointsInfo val = values [j];
                    _play.Add(val.player);
                    _play.Add(val.played.ToString());
                    _play.Add((val.points > 0 ? "+" : "") + val.points.ToString());
                }
            }
            else
            {
                _play.Add("No match found");
            }
        }
コード例 #22
0
ファイル: DemoActivity.cs プロジェクト: cryophobia/SignalR
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            var messageListAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, new List<string>());
            var messageList = FindViewById<ListView>(Resource.Id.Messages);
            messageList.Adapter = messageListAdapter;

            var connection = new Connection("http://10.0.2.2:8081/echo");
            connection.Received += data =>
                RunOnUiThread(() => messageListAdapter.Add(data));

            var sendMessage = FindViewById<Button>(Resource.Id.SendMessage);
            var message = FindViewById<TextView>(Resource.Id.Message);

            sendMessage.Click += delegate
            {
                if (!string.IsNullOrWhiteSpace(message.Text) && connection.State == ConnectionState.Connected)
                {
                    connection.Send("Android: " + message.Text);

                    RunOnUiThread(() => message.Text = "");
                }
            };

            connection.Start().ContinueWith(task => connection.Send("Android: connected"));
        }
コード例 #23
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            var client = new Client("Android");

            var input    = FindViewById <EditText>(Resource.Id.Input);
            var messages = FindViewById <ListView>(Resource.Id.Messages);

            var inputManager = (InputMethodManager)GetSystemService(InputMethodService);
            var adapter      = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, new List <string>());

            messages.Adapter = adapter;

            await client.Connect();

            input.EditorAction += delegate {
                inputManager.HideSoftInputFromWindow(input.WindowToken, HideSoftInputFlags.None);

                if (string.IsNullOrEmpty(input.Text))
                {
                    return;
                }

                client.Send(input.Text);
                input.Text = string.Empty;
            };

            client.OnMessageReceived += (sender, message) => RunOnUiThread(() => adapter.Add(message));
        }
コード例 #24
0
        private void TestSettings()
        {
            configure.CSIWebServer      = CSIWebServer.Text;
            configure.User              = User.Text;
            configure.Password          = Password.Text;
            configure.EnableHTTPS       = EnableHTTPS.Checked;
            configure.UseRESTForRequest = UseRESTForRequest.Checked;

            try
            {
                string[]     List         = configure.GetConfigurationList();
                int          DefualtIndex = 0;
                ArrayAdapter Adapter      = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem);
                for (int i = 0; i < List.Length; i++)
                {
                    Adapter.Add(List[i]);
                    if (configure.Configuration == List[i])
                    {
                        DefualtIndex = i;
                    }
                }
                Adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                Configuration.Adapter = Adapter;
                Configuration.SetSelection(DefualtIndex);
                Toast.MakeText(this, Resource.String.PassTest, ToastLength.Short).Show();
            }
            catch (Exception Ex)
            {
                Toast.MakeText(this, "TestSettings() -> " + Ex.Message, ToastLength.Short).Show();
            }
        }
コード例 #25
0
ファイル: MainActivity.cs プロジェクト: jpaberc/CampfireNet
        private void InitializeComponents()
        {
            SetContentView(Resource.Layout.Main);

            generateButton = FindViewById <Button>(Resource.Id.GenerateRoot);
            sendButton     = FindViewById <Button>(Resource.Id.Send);
            loadButton     = FindViewById <Button>(Resource.Id.Load);
            log            = FindViewById <ListView>(Resource.Id.Log);
            inputText      = FindViewById <EditText>(Resource.Id.TextInput);
            sendTextButton = FindViewById <Button>(Resource.Id.SendTextButton);

            clearButton = FindViewById <Button>(Resource.Id.ClearButton);

            logAdapter        = new ArrayAdapter <string>(this, Resource.Layout.Message);
            log.Adapter       = logAdapter;
            log.ItemsCanFocus = false;
            log.Focusable     = false;

            uiDispatchHandler = new LambdaHandler(msg => {
                if (msg.What == LOG_MESSAGE)
                {
                    logAdapter.Add((string)msg.Obj);
                    log.SmoothScrollToPosition(logAdapter.Count - 1);
                }
            });
        }
コード例 #26
0
ファイル: MainActivity.cs プロジェクト: aRvBfan/helloSpinner
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            String[] tmpString;
            tmpString = new string[9];
            int          i           = 0;
            Spinner      spinner     = FindViewById <Spinner>(Resource.Id.spinner);
            ArrayAdapter SpinnerData = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem);

            SpinnerData.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerItem);

            for (i = 0; i < 9; i++)
            {
                SpinnerData.Add(i);
                tmpString[i] = i.ToString();
            }

            spinner.Adapter = SpinnerData;


            Button button = FindViewById <Button>(Resource.Id.button1);

            button.Click += delegate {
                ButtonClick();
            };
        }
コード例 #27
0
        public void OnDeviceFound(BluetoothDevice bluetoothDevice, BluetoothClass bluetoothClass)
        {
            if (bluetoothDevice == null)
            {
                return;
            }

            bool found = false;

            // in case of rescan check the one found isn't already in our list
            foreach (BluetoothDevice device in mBluetoothDevices)
            {
                if (device.Address == bluetoothDevice.Address)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                mBluetoothDevices.Add(bluetoothDevice);
                mBluetoothArrayAdapter.Add(String.Format("{0} # {1}", bluetoothDevice.Name, bluetoothDevice.Address));
                mBluetoothArrayAdapter.NotifyDataSetChanged();
            }
        }
コード例 #28
0
        /// <summary>
        /// This is called for activities that set launchMode to "singleTop" in their package,
        /// or if a client used the <see cref="Android.Content.ActivityFlags.SingleTop"/> flag when calling
        /// <see cref="Android.Content.ContextWrapper.StartActivity(Android.Content.Intent)"/>.
        /// </summary>
        /// <param name="intent">The new intent that was started for the activity.</param>
        protected override void OnNewIntent(Intent intent)
        {
            bool isBarcodeShouldBeDeleted = intent.GetBooleanExtra("delete", false);

            // if barcode should be deleted
            if (isBarcodeShouldBeDeleted)
            {
                // if clicked item index is correct
                if (_barcodeGeneratorFragment.ClickedItemIndex != -1)
                {
                    // get adapter
                    ArrayAdapter <Utils.BarcodeInformation> adapter = _barcodeGeneratorFragment.ListAdapter as ArrayAdapter <Utils.BarcodeInformation>;
                    // remove barcode
                    adapter.Remove(adapter.GetItem(_barcodeGeneratorFragment.ClickedItemIndex));
                    adapter.NotifyDataSetChanged();
                }
            }
            else
            {
                // get barcode writer settings
                string xmlSerialization = intent.GetStringExtra("barcode");
                if (xmlSerialization != null)
                {
                    WriterSettings barcodeWriterSettings = Utils.DeserializeBarcodeWriterSettings(xmlSerialization);
                    // get barcode description
                    string barcodeDescription = intent.GetStringExtra("barcodeDescription");

                    // get barcode subset
                    string barcodeSubset = intent.GetStringExtra("barcodeSubset");
                    string barcodeValue  = intent.GetStringExtra("barcodeValue");

                    ArrayAdapter <Utils.BarcodeInformation> adapter = _barcodeGeneratorFragment.ListAdapter as ArrayAdapter <Utils.BarcodeInformation>;

                    // if barcode writer settings is not empty
                    if (barcodeWriterSettings != null)
                    {
                        // if clicked item index is correct
                        if (_barcodeGeneratorFragment.ClickedItemIndex != -1)
                        {
                            // update list item
                            Utils.BarcodeInformation item = adapter.GetItem(_barcodeGeneratorFragment.ClickedItemIndex);
                            item.BarcodeWriterSetting = barcodeWriterSettings;
                            item.BarcodeValue         = barcodeValue;
                            item.BarcodeDescription   = barcodeDescription;
                            item.BarcodeSubsetName    = barcodeSubset;
                        }
                        else
                        {
                            // add value to the list
                            adapter.Add(new Utils.BarcodeInformation(barcodeWriterSettings, barcodeValue, barcodeDescription, barcodeSubset));
                        }
                        adapter.NotifyDataSetChanged();
                    }
                }
            }

            SaveHistory();

            base.OnNewIntent(intent);
        }
コード例 #29
0
        void InitializeBluetooth()
        {
            _adapter = BluetoothAdapter.DefaultAdapter;
            if (_adapter == null)
            {
                Toast.MakeText(this, "Bluetooth is not available", ToastLength.Long).Show();
                Finish();
                return;
            }

            if (!_adapter.IsEnabled)
            {
                const int REQUEST_ENABLE_BT = 2;
                var       enableBtIntent    = new Intent(BluetoothAdapter.ActionRequestEnable);
                StartActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
            }

            ListView     list        = FindViewById <ListView>(Resource.Id.listGekoppeld);
            ArrayAdapter ListAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1);

            list.Adapter = ListAdapter;
            ListAdapter.Clear();
            foreach (BluetoothDevice dev in _adapter.BondedDevices)
            {
                ListAdapter.Add(dev.Name);
            }
            bonded.Clear();
            bonded.AddRange(_adapter.BondedDevices);
        }
コード例 #30
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.agregarproductolayout);
            nameproductocreadotxt        = FindViewById <EditText>(Resource.Id.nameproductocreadotxt);
            productodescpcioncreaciontxt = FindViewById <EditText>(Resource.Id.productodescpcioncreaciontxt);
            precioproductotxt            = FindViewById <EditText>(Resource.Id.precioproductotxt);
            timpoentregatxt              = FindViewById <EditText>(Resource.Id.timpoentregatxt);
            descuentocreatetxt           = FindViewById <EditText>(Resource.Id.descuentocreatetxt);
            productoimagencreacion       = FindViewById <ImageView>(Resource.Id.productoimagencreacion);
            creacionproductofinalizarbtn = FindViewById <Button>(Resource.Id.creacionproductofinalizarbtn);
            productotipodecomidaspn      = FindViewById <Spinner>(Resource.Id.productotipodecomidaspn);
            fotoproductobtn              = FindViewById <Button>(Resource.Id.fotoproductobtn);

            string          sql = string.Format("SELECT TipoDeComida FROM TapFood.Comida");
            MySqlCommand    cty = new MySqlCommand(sql, conn);
            MySqlDataReader plz;

            plz = cty.ExecuteReader();

            var tipos = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem);

            while (plz.Read())
            {
                tipos.Add(" " + plz["TipoDeComida"].ToString() + "");
            }
            productotipodecomidaspn.Adapter = tipos;
            plz.Close();

            fotoproductobtn.Click += fotoproductobtn_Click;
            creacionproductofinalizarbtn.Click += Creacionproductofinalizarbtn_Click;
        }
コード例 #31
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //CastManager.Initialize(this.ApplicationContext, NameSpace);
            //_castManager = CastManager.GetCastManager();
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.start_view);
            var miniControllerFragment = (MiniControllerFragment)SupportFragmentManager.FindFragmentById(Resource.Id.cast_mini_controller);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            //SetContentView(Resource.Layout.Main);
            _videoList = GetVideoList();

            var listview = FindViewById <ListView>(Resource.Id.listView);

            var adapter = new ArrayAdapter <string>(context: this, textViewResourceId: Resource.Layout.list_activity_list_item);

            foreach (var video in _videoList)
            {
                adapter.Add(video.Title);
            }
            listview.Adapter    = adapter;
            listview.ItemClick += Listview_ItemClick;
        }
コード例 #32
0
            public override void OnReceive(Context context, Intent intent)
            {
                String action = intent.Action;

                if (BluetoothDevice.ActionFound.Equals(action))
                {
                    BluetoothDevice device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);

                    try
                    {
                        if (btDevices == null)
                        {
                            btDevices = new ArrayAdapter <BluetoothDevice>(Application.Context, Resource.Layout.layout_list);
                        }

                        if (btDevices.GetPosition(device) < 0)
                        {
                            btDevices.Add(device);
                            mArrayAdapter.Add(device.Name + "\n" + device.Address + "\n");
                            mArrayAdapter.NotifyDataSetInvalidated();
                        }
                    }
                    catch (Exception ex)
                    {
                        //ex.fillInStackTrace();
                    }
                }
            }
コード例 #33
0
        public static ArrayAdapter <String> GetAreas(Context context)
        {
            try
            {
                const string requestUrl = ApiUrl + "GetAreas";
                var          response   = Get(requestUrl, "");

                var ordersXDocument = XDocument.Parse(response);

                var areas = new ArrayAdapter <String>(context, Android.Resource.Layout.SelectDialogSingleChoice);

                foreach (var cElement in ordersXDocument.Root.Elements())
                {
                    areas.Add(cElement.Element("title").Value);

                    UserInfo.AreasId.Add(int.Parse(cElement.Element("ID").Value));
                }

                return(areas);
            }
            catch
            {
                return(null);
            }
        }
コード例 #34
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            MyEditText = FindViewById <EditText>(Resource.Id.MyEditText);
            MyButton   = FindViewById <Button>(Resource.Id.MyButton);
            MyListView = FindViewById <ListView>(Resource.Id.MyListView);

            items = new List <string>();
            items.Add("吃早餐");

            adapter = new ArrayAdapter <string>
                          (this, Android.Resource.Layout.SimpleListItem1, items);
            MyListView.Adapter = adapter;

            MyButton.Click += delegate {
                adapter.Add(MyEditText.Text);
                adapter.NotifyDataSetChanged();

                Toast.MakeText(this, $"{MyEditText.Text} 已添加", ToastLength.Short)
                .Show();
            };
        }
コード例 #35
0
 public EndlessScrollListener(ArrayAdapter<DateTime> adapter)
 {
     this.adapter = adapter;
     for (int i = 0; i < chunksize*2; i++) {
         adapter.Add (DateTime.Now.AddDays (i));
     };
 }
コード例 #36
0
ファイル: MainActivity.cs プロジェクト: jcambert/MVA-SignalR
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            var client = new Client("Android");

            var input = FindViewById<EditText>(Resource.Id.Input);
            var messages = FindViewById<ListView>(Resource.Id.Messages);

            var inputManager = (InputMethodManager)GetSystemService(InputMethodService);
            var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, new List<string>());

            messages.Adapter = adapter;

            await client.Connect();

            input.EditorAction +=
              delegate
              {
                  inputManager.HideSoftInputFromWindow(input.WindowToken, HideSoftInputFlags.None);

                  if (string.IsNullOrEmpty(input.Text))
                      return;

                  client.Send(input.Text);

                  input.Text = "";
              };

            client.OnMessageReceived +=
              (sender, message) => RunOnUiThread(() =>
                adapter.Add(message));
        }
コード例 #37
0
ファイル: MainActivity.cs プロジェクト: Redth/square-bindings
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            Button startTest = FindViewById<Button>(Resource.Id.startTest);
            ListView listView = FindViewById<ListView>(Resource.Id.listView);

            startTest.Click += delegate
            {
                ArrayAdapter<string> adapter = new ArrayAdapter<string>(
                    this,
                    Android.Resource.Layout.SimpleListItem1,
                    Android.Resource.Id.Text1);
                listView.Adapter = adapter;

                OkHttpClient client = new OkHttpClient();

                // Create request for remote resource.
                Request request = new Request.Builder()
                    .Url(Endpoint)
                    .Build();

                // Execute the request and retrieve the response.
                WebSocketCall call = WebSocketCall.Create(client, request);
                WebSocketListener listener = call.Enqueue();

                // attach handlers to the various events
                listener.Close += (sender, e) =>
                {
                    RunOnUiThread(() => adapter.Add(string.Format("{0}: {1}", e.Code, e.Reason)));
                };
                listener.Failure += (sender, e) =>
                {
                    if (e.Exception != null)
                        RunOnUiThread(() => adapter.Add(e.Exception.Message));
                    else
                        RunOnUiThread(() => adapter.Add("Unknown Error!"));
                };
                listener.Message += (sender, e) =>
                {
                    string payload = e.Payload.String();
                    e.Payload.Close();
					RunOnUiThread(() => adapter.Add(string.Format("{0}\n{1}", payload, e.Payload.ContentType())));
                };
                listener.Open += (sender, e) =>
                {
                    RunOnUiThread(() => adapter.Add("Opened Web Socket."));

                    StartMessages(e.WebSocket);
                };
                listener.Pong += (sender, e) =>
                {
                    string payload = e.Payload.ReadString(Charset.DefaultCharset());
                    e.Payload.Close();
                    RunOnUiThread(() => adapter.Add(payload));
                };
            };
        }
コード例 #38
0
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			RequestWindowFeature(WindowFeatures.NoTitle);
			Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

			//Show a list of available samples (click to run):
			ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Resource.Layout.samples_list_text_view);
			sampleTypes = typeof(Sample).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Application)) && t != typeof(Sample)).ToArray();
			foreach (var sample in sampleTypes)
			{
				adapter.Add(sample.Name);
			}
			SetContentView(Resource.Layout.samples_list);
			ListAdapter = adapter;
		}
コード例 #39
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			SetContentView (Resource.Layout.activity_animator_sample);

			var toolbar = FindViewById<Toolbar> (Resource.Id.tool_bar);
			SetSupportActionBar (toolbar);
			SupportActionBar.SetDisplayShowTitleEnabled (false);

			var recyclerView = FindViewById<RecyclerView> (Resource.Id.list);

			if (Intent.GetBooleanExtra ("GRID", true)) {
				recyclerView.SetLayoutManager (new GridLayoutManager (this, 2));
			} else {
				recyclerView.SetLayoutManager (new LinearLayoutManager (this));
			}

			recyclerView.SetItemAnimator (new SlideInLeftAnimator ());

			var adapter = new MainAdapter (this, data.ToList ());
			recyclerView.SetAdapter (adapter);

			var spinner = FindViewById<Spinner> (Resource.Id.spinner);
			var spinnerAdapter = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleListItem1);
			foreach (var type in AnimatorTypes) {
				spinnerAdapter.Add (type.Key);
			}
			spinner.Adapter = spinnerAdapter;
			spinner.ItemSelected += (sender, e) => {
				recyclerView.SetItemAnimator (AnimatorTypes.Values.ToArray () [e.Position]);
				recyclerView.GetItemAnimator ().AddDuration = 500;
				recyclerView.GetItemAnimator ().RemoveDuration = 500;
			};

			FindViewById (Resource.Id.add).Click += (sender, e) => {
				adapter.Add ("newly added item", 1);
			};

			FindViewById (Resource.Id.del).Click += (sender, e) => {
				adapter.Remove (1);
			};
		}
コード例 #40
0
ファイル: Activity1.cs プロジェクト: zizifn/TestProjectDaily
        private void Wc_DownloadStringCompleted(String result)
        {


            JsonObject jo = (JsonObject)JsonValue.Parse(result);

            ArrayAdapter<CategoryInfo> adapter = new ArrayAdapter<CategoryInfo>(this, Android.Resource.Layout.SimpleListItem1);
            JsonValue jvs = null;
            jo.TryGetValue("content", out jvs);

            foreach(JsonObject jv in jvs)
            {
                CategoryInfo info = new CategoryInfo();
                JsonValue id = null;
                jv.TryGetValue("category_id", out id);

                JsonValue order = null;
                jv.TryGetValue("order", out order);

                JsonValue text = null;
                jv.TryGetValue("text", out text);

                JsonValue isadd = null;
                jv.TryGetValue("isadd", out isadd);

                info.category_id = id;
                info.order = order;
                info.text = text;
                info.isadd = isadd;

                adapter.Add(info);
            }

            ListView lv = FindViewById<ListView>(Resource.Id.lVCategoryAll);
            lv.Adapter = adapter;
            lv.ItemClick += Lv_ItemClick;

           // lv.Touch += Lv_Touch;


        }
コード例 #41
0
ファイル: Login.cs プロジェクト: eatage/AppTest.bak
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Login);

            TextView web_title = FindViewById<TextView>(Resource.Id.login_msg);
            Spinner spinner = FindViewById<Spinner>(Resource.Id.login_group);
            Button btn_cancel = FindViewById<Button>(Resource.Id.login_cancel);
            Button btn_login = FindViewById<Button>(Resource.Id.login_submit);
            TextView Refresh= FindViewById<TextView>(Resource.Id.login_Refresh);

            string CompanyList = publicfuns.of_GetMySysSet("Login", "CompanyList");
            string CompanyHost = publicfuns.of_GetMySysSet("Login", "CompanyHost");
            if (string.IsNullOrEmpty(CompanyList) || string.IsNullOrEmpty(CompanyList))
            {
                CompanyList = YW.of_GetCompanyList(SysVisitor.MEID(this));
                CompanyHost = YW.of_GetCompanyHost(SysVisitor.MEID(this));
            }
            string[] list = { };
            string[] host = { };
            if (CompanyList.Substring(0, 2) == "OK" && CompanyHost.Substring(0, 2) == "OK")
            {
                list = CompanyList.Substring(2).Split(',');
                publicfuns.of_SetMySysSet("Login", "CompanyList", CompanyList);
                host = CompanyHost.Substring(2).Split(',');
                publicfuns.of_SetMySysSet("Login", "CompanyHost", CompanyHost);
            }
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < list.Length; i++)
            {
                adapter.Add(list[i]);
            }
            spinner.Adapter = adapter;


            //string name = Intent.GetStringExtra("Name");
            //int age = Intent.GetIntExtra("Age", -1);
            //string str = "Your Name is " + name + ", Age is " + age + " MEID:" + Core.SysVisitor.MEID(this);
            //byte[] buff = System.Text.Encoding.UTF8.GetBytes(str);
            //str = Core.Zip.CompressByteToStr(buff);
            //str = Core.Zip.Decompress(str);

            if (!SysVisitor.isNetworkConnected(this))
            {
                web_title.Text = "未连接到网络";
            }

            spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);

            btn_cancel.Click += delegate
            {
                SysVisitor.EXIT(this);
            };
            //登陆
            btn_login.Click += delegate
            {
                EditText username = FindViewById<EditText>(Resource.Id.login_username);
                EditText password = FindViewById<EditText>(Resource.Id.login_pass);
                string ls_username = username.Text;
                string ls_password = password.Text;
                if(string.IsNullOrEmpty(ls_username)||string.IsNullOrEmpty(ls_password))
                {
                    Toast.MakeText(this, "用户名或密码不能为空", ToastLength.Long).Show();
                }
                ls_password = Core.DES.of_EncryStrVc(ls_password, ls_username);
                string ls_params = "action=getcustomer&driverno=" + SysVisitor.MEID(this) + "&username="******"&password="******"[{");
                if (row >= 0)
                {
                    str = str.Substring(row);
                }
                if (str=="OK")
                {
                    //登陆成功
                    Toast.MakeText(this, "", ToastLength.Long).Show();
                }
                else
                {
                    Toast.MakeText(this, str, ToastLength.Long).Show();
                }
            };
            //刷新登陆数据
            Refresh.Click += delegate 
            {
                CompanyList = "";
                CompanyHost = "";
                Boolean ls_Refresh = false;
                if (string.IsNullOrEmpty(CompanyList) || string.IsNullOrEmpty(CompanyList))
                {
                    CompanyList = YW.of_GetCompanyList(SysVisitor.MEID(this));
                    CompanyHost = YW.of_GetCompanyHost(SysVisitor.MEID(this));
                }
                if (CompanyList.Substring(0, 2) == "OK" && CompanyHost.Substring(0, 2) == "OK")
                {
                    list = CompanyList.Substring(2).Split(',');
                    publicfuns.of_SetMySysSet("Login", "CompanyList", CompanyList);
                    host = CompanyHost.Substring(2).Split(',');
                    publicfuns.of_SetMySysSet("Login", "CompanyHost", CompanyHost);
                    ls_Refresh = true;
                }
                spinner.Invalidate();//刷新该控件
                if(ls_Refresh)
                {
                    Toast.MakeText(this, "登陆数据已成功刷新", ToastLength.Long).Show();
                }
                else
                {
                    Toast.MakeText(this, "刷新失败", ToastLength.Long).Show();
                }
            };
        }
コード例 #42
0
ファイル: Activity1.cs プロジェクト: vladkats/ContestProject
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Проверка поступления письма от работодателя
            if (Intent.GetStringExtra("id") == null)
            {
                SetContentView(Resource.Layout.ActivityLayout1);
                name = FindViewById<EditText>(Resource.Id.name);
                salary = FindViewById<EditText>(Resource.Id.salary);
                phone = FindViewById<EditText>(Resource.Id.phone);
                email = FindViewById<EditText>(Resource.Id.email);
                gender = FindViewById<Spinner>(Resource.Id.gender);
                jobPosition = FindViewById<EditText>(Resource.Id.jobPosition);

                //Адаптер для элемента Spinner
                aas = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
                gender.Adapter = aas;
                aas.Add(String.Empty);
                aas.Add("Мужской");
                aas.Add("Женский");
                gender.ItemSelected += sp_ItemSelected;

                submit = FindViewById<Button>(Resource.Id.submit);
                submit.Click += button_Clicked;
            }

            else
            {

                SetContentView(Resource.Layout.activityLayoutDialog);
                dialogWindow();

                index = Intent.GetStringExtra("id");
                int id = 0;

                id = int.Parse(index);
                ans = new Answer();
                ans.id = id;
                ans.text = Intent.GetStringExtra("answer");

                // Отображение списка писем в ListView
                _answerList = FindViewById<ListView>(Resource.Id.answers);
                _answerList.Visibility = ViewStates.Visible;
                _answer = new List<Answer>();
                _answer.Add(ans);
                _answerList.Adapter = new answerListAdapter(this, _answer);

                EditText backLetter = FindViewById<EditText>(Resource.Id.backLetter);
                Button sendBack = FindViewById<Button>(Resource.Id.btn_sendBack);
                int count = 1;
                sendBack.Click += delegate
                {
                    Answer answer = new Answer();
                    answer.id = count;
                    answer.text = backLetter.Text;
                    _answer.Add(answer);
                    _answerList.Adapter = new answerListAdapter(this, _answer);
                    backLetter.Text = String.Empty;
                    count++;
                };
            }
        }
コード例 #43
0
ファイル: backmoneyrecord.cs プロジェクト: eatage/AppTest
 void sp_type_ItemSelected(Object sender, AdapterView.ItemSelectedEventArgs e)//选取付款方式 现金or刷卡
 {
     Spinner spinner = (Spinner)sender;
     as_type = spinner.GetItemAtPosition(e.Position).ToString();
     var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
     Spinner sp_bank = FindViewById<Spinner>(Resource.Id.backmoneyrecord_bank);
     if (as_type == "现金")
     {
         DataTable ldt_type = new DataTable();
         ldt_type = SqliteHelper.ExecuteDataTable("select accname FROM accsubject where oneaccno like '101%'");
         adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
         for (int i = 0; i < ldt_type.Rows.Count; i++)
         {
             adapter.Add(ldt_type.Rows[i]["accname"].ToString());
         }
         sp_bank.Adapter = adapter;
     }
     if (as_type == "银行")
     {
         DataTable ldt_type = new DataTable();
         ldt_type = SqliteHelper.ExecuteDataTable("select accname FROM accsubject where oneaccno like '102%'");
         adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
         for (int i = 0; i < ldt_type.Rows.Count; i++)
         {
             adapter.Add(ldt_type.Rows[i]["accname"].ToString());
         }
         sp_bank.Adapter = adapter;
     }
 }
コード例 #44
0
ファイル: MainActivity.cs プロジェクト: eatage/AppTest.bak
        /// <summary>
        /// 选择分组 刷新用户名列表
        /// </summary>
        void group_ItemSelected(Object sender, AdapterView.ItemSelectedEventArgs e)
        {
            Spinner spinner = (Spinner)sender;
            string groupname = spinner.GetItemAtPosition(e.Position).ToString();

            Spinner username = FindViewById<Spinner>(Resource.Id.login_username);
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            DataTable ldt = new DataTable();
            string ls_gid = "";
            ls_gid = SqliteHelper.ExecuteScalar("select gid from mygroup where groupname='" + groupname + "'");
            ldt = SqliteHelper.ExecuteDataTable("select username from myuser where gid='" + ls_gid + "'");
            for (int i = 0; i < ldt.Rows.Count; i++)
            {
                adapter.Add(ldt.Rows[i]["username"].ToString());
            }
            username.Adapter = adapter;
        }
コード例 #45
0
ファイル: MainActivity.cs プロジェクト: eatage/AppTest.bak
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Main);

            #region 测试时使用
            //string ls_path = "/sdcard/gysoft/";
            //if (!Directory.Exists(ls_path))
            //{
            //    Directory.CreateDirectory(ls_path);
            //}
            #endregion
            //if (!string.IsNullOrEmpty(_publicfuns.of_GetMySysSet("Login", "username")))
            //{
            //    ParameterizedThreadStart ParStart = new ParameterizedThreadStart(Sync.CheckPhone);
            //    Thread thread = new Thread(ParStart);
            //    thread.Start(this);
            //}
            if (SysVisitor.getVersionCode(this) != -1)
            {
                _publicfuns.of_SetMySysSet("app", "vercode", SysVisitor.getVersionCode(this).ToString());
            }
            if (SysVisitor.getVersionName(this) != "")
            {
                _publicfuns.of_SetMySysSet("app", "vername", SysVisitor.getVersionName(this));
            }
            _publicfuns.of_SetMySysSet("phone", "meid", SysVisitor.MEID(this));
            #region 自动登录
            if (_publicfuns.of_GetMySysSet("Login", "Login") == "Y")
            {
                string ls_user = _publicfuns.of_GetMySysSet("Login", "username");
                string ls_pwd = _publicfuns.of_GetMySysSet("Login", "password");
                string ls_logindate = _publicfuns.of_GetMySysSet("Login", "logindate");
                if (!string.IsNullOrEmpty(ls_user) && !string.IsNullOrEmpty(ls_pwd))
                {
                    DateTime time;
                    try
                    {
                        time = Convert.ToDateTime(ls_logindate);
                    }
                    catch
                    {
                        time = DateTime.Now.AddDays(-100);
                    }
                    if (SysVisitor.Current.DateDiff(time.ToString(), DateTime.Now.ToString(), "Days") <= 7)
                    {
                        SysVisitor.UserName = ls_user;
                        Intent it = new Intent();
                        Bundle bu = new Bundle();
                        bu.PutString("name", "data");
                        bu.PutString("update", "");
                        it.PutExtras(bu);
                        it.SetClass(this.ApplicationContext, typeof(Index));
                        StartActivity(it);
                        Finish();
                        return;
                    }
                }
            }
            #endregion
            string ls_DeviceId = SysVisitor.MEID(this);

            TextView web_title = FindViewById<TextView>(Resource.Id.login_msg);
            Spinner spinner = FindViewById<Spinner>(Resource.Id.login_company);
            Spinner spinner_mygroup = FindViewById<Spinner>(Resource.Id.login_group);
            Spinner username = FindViewById<Spinner>(Resource.Id.login_username);
            Button btn_cancel = FindViewById<Button>(Resource.Id.login_cancel);
            Button btn_login = FindViewById<Button>(Resource.Id.login_submit);
            TextView Refresh = FindViewById<TextView>(Resource.Id.login_Refresh);
            EditText password = FindViewById<EditText>(Resource.Id.login_pass);
            CheckBox chk_showpwd = FindViewById<CheckBox>(Resource.Id.login_showpwd);//显示密码
            CheckBox chk_login = FindViewById<CheckBox>(Resource.Id.login_checklogin);//自动登录

            bool lb_db = SqliteHelper.of_ExistDataBase();
            new CreateTable();

            string CompanyList = _publicfuns.of_GetMySysSet("Login", "CompanyList");
            string CompanyHost = _publicfuns.of_GetMySysSet("Login", "CompanyHost");
            //未获取到本地数据  从服务器获取
            if (string.IsNullOrEmpty(CompanyList) || string.IsNullOrEmpty(CompanyHost))
            {
                Intent it = new Intent();
                Bundle bu = new Bundle();
                bu.PutString("name", "login");
                it.PutExtras(bu);
                it.SetClass(this.ApplicationContext, typeof(Loading));
                StartActivity(it);
                Finish();
                return;
            }
            string[] list = { };
            if (CompanyList.Substring(0, 2) == "OK")
            {
                list = CompanyList.Substring(2).Split(',');
            }
            if (CompanyHost.Substring(0, 2) == "OK")
            {
                _publicfuns.of_SetMySysSet("Login", "CompanyHost", CompanyHost);
            }
            if (!lb_db)//首次创建数据库
            {
                //加载mygroup 与myuser表数据
                Intent it = new Intent();
                Bundle bu = new Bundle();
                bu.PutString("table", "login");
                bu.PutString("name", "正在刷新登陆数据");
                it.PutExtras(bu);
                it.SetClass(this.ApplicationContext, typeof(Loading));
                StartActivity(it);
                Finish();
                return;
            }
            #region 为控件绑定数据
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < list.Length; i++)
            {
                adapter.Add(list[i]);
            }
            spinner.Adapter = adapter;
            spinner.SetSelection(list.Length - 1, true);//默认选中项
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            DataTable ldt = new DataTable();
            ldt = SqliteHelper.ExecuteDataTable("select groupname from mygroup");
            for (int i = 0; i < ldt.Rows.Count; i++)
            {
                adapter.Add(ldt.Rows[i]["groupname"].ToString());
            }
            spinner_mygroup.Adapter = adapter;

            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            ldt = new DataTable();
            string ls_gid = "";
            ls_gid = SqliteHelper.ExecuteScalar("select gid from mygroup");
            ldt = SqliteHelper.ExecuteDataTable("select username from myuser where gid='" + ls_gid + "'");
            for (int i = 0; i < ldt.Rows.Count; i++)
            {
                adapter.Add(ldt.Rows[i]["username"].ToString());
            }
            username.Adapter = adapter;
            #endregion
            //if (!SysVisitor.isNetworkConnected(this))
            //{
            //    web_title.Text = "未连接到网络";
            //}

            spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            spinner_mygroup.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(group_ItemSelected);

            chk_showpwd.CheckedChange += delegate 
            {
                if (chk_showpwd.Checked)
                {
                    password.InputType = Android.Text.InputTypes.TextVariationWebEditText;
                }
                else
                {
                    password.InputType= Android.Text.InputTypes.ClassText| Android.Text.InputTypes.TextVariationPassword;
                }
                password.SetSelection(password.Text.Length);
            };
            
            btn_cancel.Click += delegate
            {
                SysVisitor.EXIT(this);
            };

            //登陆
            btn_login.Click += delegate
            {
                string local_user = _publicfuns.of_GetMySysSet("Login", "username");
                string local_pwd = _publicfuns.of_GetMySysSet("Login", "password");
                string local_logindate = _publicfuns.of_GetMySysSet("Login", "logindate");

                string ls_username = username.SelectedItem.ToString();
                string ls_password = password.Text;

                string ls_Login = "";
                DateTime time;
                try
                {
                    time = Convert.ToDateTime(local_logindate);
                }
                catch
                {
                    time = DateTime.Now.AddDays(-100);
                }
                if (SysVisitor.Current.DateDiff(time.ToString(), DateTime.Now.ToString(), "Days") <= 7)
                {
                    if (!string.IsNullOrEmpty(local_user) && !string.IsNullOrEmpty(local_pwd))
                    {
                        if (local_user == ls_username && local_pwd == baseclass.DES.of_EncryStr_64(ls_password, "loginpasskey"))
                        {
                            ls_Login = "******";//本地账号密码校验成功
                                            //测试时关闭本地校验
                        }
                    }
                }
                if (string.IsNullOrEmpty(ls_Login))//未完成本地登陆
                {
                    string ls_error = YW.of_GetCompanyList(ls_DeviceId);
                    if (ls_error.Substring(0, 2) != "OK")
                    {
                        //Toast.MakeText(this, "该手机未注册,请重新注册", ToastLength.Long).Show();
                        //return;
                        StartActivity(typeof(enroll));
                        Finish();
                        return;
                    }
                    YW.of_GetERPurl(SysVisitor.Get_Comname(), ls_DeviceId);
                    ls_error = YW.of_CheckNetWorkOK();
                    if (ls_error != "OK")
                    {
                        Toast.MakeText(this, "未能成功连接服务器,请重试", ToastLength.Long).Show();
                        return;
                    }
                    ls_Login = YW.Of_loginYW(SysVisitor.Get_Comname(), ls_username, ls_password);//登陆
                }

                //YW.SendMessage_MygroupUser_json();
                if (string.IsNullOrEmpty(ls_username) || string.IsNullOrEmpty(ls_password))
                {
                    Toast.MakeText(this, "用户名或密码不能为空", ToastLength.Long).Show();
                }

                if (ls_Login == "OK")
                {
                    _publicfuns.of_SetMySysSet("Login", "username", ls_username);
                    _publicfuns.of_SetMySysSet("Login", "password", baseclass.DES.of_EncryStr_64(ls_password, "loginpasskey"));
                    _publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.ToString());
                    if (chk_login.Checked)//下次自动登录
                    {
                        _publicfuns.of_SetMySysSet("Login", "Login", "Y");
                    }
                    else
                    {
                        _publicfuns.of_SetMySysSet("Login", "Login", "N");
                    }
                    //登陆成功
                    string ls_row = SqliteHelper.ExecuteScalar("select count(*) from customer");
                    int row = 0;
                    try
                    {
                        row = int.Parse(ls_row);
                    }
                    catch { }
                    Toast.MakeText(this, "登陆成功", ToastLength.Short).Show();
                    Intent it = new Intent();
                    Bundle bu = new Bundle();
                    bu.PutString("name", "data");
                    bu.PutString("update", "");
                    it.PutExtras(bu);
                    if (row <= 0)
                    {
                        it.SetClass(this.ApplicationContext, typeof(Loading));
                    }
                    else
                    {
                        it.SetClass(this.ApplicationContext, typeof(Index));
                    }
                    SysVisitor.UserName = ls_username;
                    StartActivity(it);
                    Finish();
                }
                else
                {
                    Toast.MakeText(this, "登陆失败,请检查网络设置,请检查用户名密码", ToastLength.Long).Show();
                }
            };

            //Android.Views.InputMethods.InputMethodManager imm = (Android.Views.InputMethods.InputMethodManager)GetSystemService(Context.InputMethodService);
            //imm.HideSoftInputFromWindow(btn_login.WindowToken, Android.Views.InputMethods.HideSoftInputFlags.None);
            //刷新登陆数据
            Refresh.Click += delegate
            {
                Intent it = new Intent();
                Bundle bu = new Bundle();
                bu.PutString("name", "login");
                it.PutExtras(bu);
                it.SetClass(this.ApplicationContext, typeof(Loading));
                StartActivity(it);
                Finish();
            };

        }
コード例 #46
0
ファイル: MainActivity.cs プロジェクト: eatage/AppTest
        bool ab_shouNetType;//是否手动禁止显示未联网状态显示
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Main);
            if (string.IsNullOrEmpty(baseclass.MyConfig.of_GetMySysSet("COMPANY", "CompanyName")))
            {
                Core.SysVisitor.CreateServerDB();
                string ls_sql = "select Itemvalue from mysysset where ItemType='COMPANY' and itemName='CompanyName'";
                string ls_CompanyName = SqlHelper.ExecuteScalar(ls_sql);
                if (!string.IsNullOrEmpty(ls_CompanyName))
                {
                    baseclass.MyConfig.of_SetMySysSet("COMPANY", "CompanyName", ls_CompanyName);
                }
            }
            if (string.IsNullOrEmpty(MyConfig.of_GetMySysSet("printer", "memo")))
            {

            }
            GyERP.CompanyName = baseclass.MyConfig.of_GetMySysSet("COMPANY", "CompanyName");
            if (SysVisitor.getVersionCode(this) != -1)
                MyConfig.of_SetMySysSet("app", "vercode", SysVisitor.getVersionCode(this).ToString());
            if (SysVisitor.getVersionName(this) != "")
                MyConfig.of_SetMySysSet("app", "vername", SysVisitor.getVersionName(this));
            MyConfig.of_SetMySysSet("phone", "meid", SysVisitor.MEID(this));
            #region 自动登录
            if (MyConfig.of_GetMySysSet("Login", "Login") == "Y")
            {
                string ls_user = MyConfig.of_GetMySysSet("Login", "username");
                string ls_pwd = MyConfig.of_GetMySysSet("Login", "password");
                string ls_logindate = MyConfig.of_GetMySysSet("Login", "logindate");
                if (!string.IsNullOrEmpty(ls_user) && !string.IsNullOrEmpty(ls_pwd))
                {
                    DateTime time;
                    try
                    {
                        time = Convert.ToDateTime(ls_logindate);
                    }
                    catch
                    {
                        time = DateTime.Now.AddDays(-100);
                    }
                    if (SysVisitor.DateDiff(time.ToString(), SysVisitor.timeSpan.Days) <= 7)
                    {
                        GyERP.UserName = ls_user;
                        Intent it = new Intent();
                        Bundle bu = new Bundle();
                        bu.PutString("name", "data");
                        bu.PutString("update", "");
                        it.PutExtras(bu);
                        it.SetClass(this.ApplicationContext, typeof(Index));
                        StartActivity(it);
                        Finish();
                        return;
                    }
                }
            }
            #endregion
            string ls_DeviceId = SysVisitor.MEID(this);

            Spinner sp_comname = FindViewById<Spinner>(Resource.Id.login_company);
            Spinner sp_mygroup = FindViewById<Spinner>(Resource.Id.login_group);
            Spinner username = FindViewById<Spinner>(Resource.Id.login_username);
            Button btn_cancel = FindViewById<Button>(Resource.Id.login_cancel);
            Button btn_login = FindViewById<Button>(Resource.Id.login_submit);
            TextView Refresh = FindViewById<TextView>(Resource.Id.login_Refresh);
            EditText password = FindViewById<EditText>(Resource.Id.login_pass);
            CheckBox chk_showpwd = FindViewById<CheckBox>(Resource.Id.login_showpwd);//显示密码
            CheckBox chk_login = FindViewById<CheckBox>(Resource.Id.login_checklogin);//自动登录
            TextView txt_msg = FindViewById<TextView>(Resource.Id.login_text);//底部说明文字
            Button btn_login_b = FindViewById<Button>(Resource.Id.login_Btn_LoginB);

            password.Click += delegate
            {
                //AlertDialog.Builder builder = new AlertDialog.Builder(this);
                //var et_search = new EditText(this);
                //et_search.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;
                //builder.SetTitle("提示:");
                //builder.SetMessage("请输入密码:");
                //builder.SetView(et_search);
                //builder.SetNegativeButton("确定", delegate
                //{
                //    if (et_search.Text != "")
                //        password.Text = et_search.Text;
                //});
                //builder.SetPositiveButton("确定并登陆", delegate
                //{
                //    if (et_search.Text != "")
                //        password.Text = et_search.Text;
                //    btn_login.PerformClick();
                //});
                //builder.Show();
                if (password.Text != "")
                    password.SetSelectAllOnFocus(true);
            };
            btn_login_b.Click += delegate
            {
                btn_login.PerformClick();
            };

            string ls_comname = LocalYW.of_GetMySysSet("comname", "defaultcomname");    //取到上次登录comname
            string ls_defaultusername = LocalYW.of_GetMySysSet("comname", "defaultusername");   //取到上次登录人

            //int li_row = MyConfig.ExecuteScalarNum("select count(*) from customer");
            if (string.IsNullOrEmpty(ls_comname))
            {
                txt_msg.Text = "首次登陆时需要从服务器获取大量数据\n可能需要几分钟甚至更长时间\n建议在网络条件较好的环境下操作\n获取数据过程中请不要关闭程序";
            }
            //bool lb_db = SqliteHelper.of_ExistDataBase();
            new CreateTable();

            string ls_CompanyListSQL = @"select itemvalue from mysysset where itemtype=@itemtype order by itemname";
            DataTable ldt_comanyList = MyConfig.ExecuteDataTable(GyERP.ConfigPath + "config.db", CommandType.Text, ls_CompanyListSQL, "@itemtype=YWcompanylist");

            #region 为控件绑定数据
            int li_comnameRow = 0;
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < ldt_comanyList.Rows.Count; i++)
            {
                if (ls_comname == ldt_comanyList.Rows[i][0].ToString())
                    li_comnameRow = i;
                adapter.Add(ldt_comanyList.Rows[i][0].ToString());
            }
            sp_comname.Adapter = adapter;
            sp_comname.SetSelection(li_comnameRow, true);//默认选中项

            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            DataTable ldt = new DataTable();
            ldt = MyConfig.ExecuteDataTable("select groupname from mygroup");
            for (int i = 0; i < ldt.Rows.Count; i++)
            {
                adapter.Add(ldt.Rows[i]["groupname"].ToString());
            }
            sp_mygroup.Adapter = adapter;

            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            ldt = new DataTable();
            string ls_gid = "";
            ls_gid = MyConfig.ExecuteScalar("select gid from mygroup");
            ldt = MyConfig.ExecuteDataTable("select username from myuser where gid='" + ls_gid + "'");
            for (int i = 0; i < ldt.Rows.Count; i++)
            {
                adapter.Add(ldt.Rows[i]["username"].ToString());
            }
            username.Adapter = adapter;
            #endregion
            sp_comname.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(sp_comname_ItemSelected);
            sp_mygroup.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(sp_group_ItemSelected);
             
            chk_showpwd.CheckedChange += delegate
            {
                if (chk_showpwd.Checked)
                {
                    password.InputType = Android.Text.InputTypes.TextVariationWebEditText;
                }
                else
                {
                    password.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;
                }
                password.SetSelection(password.Text.Length);
            };

            btn_cancel.Click += delegate
            {
                SysVisitor.EXIT(this);
            };

            //登陆
            btn_login.Click += delegate
            {
                string local_user = MyConfig.of_GetMySysSet("Login", "username");
                string local_pwd = MyConfig.of_GetMySysSet("Login", "password");
                string local_logindate = MyConfig.of_GetMySysSet("Login", "logindate");

                string ls_username = username.SelectedItem.ToString();
                string ls_password = password.Text;

                string ls_Login = "";
                DateTime time = baseclass.GyConvert.of_ToDatetime(local_logindate);
                #region 本地登陆


                ls_Login = GyERP.of_SetUserInfo(GyERP.ComName, ls_username, ls_password);
                if (baseclass.GYstring.of_LeftStr(ls_Login, 2) != "OK")
                {
                    Toast.MakeText(this, "用户名或密码错误,请重新输入", ToastLength.Short).Show();
                    return;
                }
                if (SysVisitor.DateDiff(time.ToString(), SysVisitor.timeSpan.Days) <= 7)
                {
                    if (!string.IsNullOrEmpty(local_user) && !string.IsNullOrEmpty(local_pwd))
                    {
                        if (local_user == ls_username && local_pwd == baseclass.DES.of_EncryStr_64(ls_password, "loginpasskey"))
                        {
                            ls_Login = "******";//本地账号密码校验成功
                                            //测试时关闭本地校验
                        }
                    }
                }
                if (string.IsNullOrEmpty(ls_Login))//未完成本地登陆
                {
                }
                #endregion
                if (string.IsNullOrEmpty(ls_username) || string.IsNullOrEmpty(ls_password))
                {
                    Toast.MakeText(this, "用户名或密码不能为空", ToastLength.Short).Show();
                    return;
                }
                #region 登陆成功
                if (ls_Login == "OK")
                {
                    MyConfig.of_SetMySysSet("Login", "username", ls_username);
                    MyConfig.of_SetMySysSet("Login", "password", baseclass.DES.of_EncryStr_64(ls_password, "loginpasskey"));
                    //_publicfuns.of_SetMySysSet("Login", "password-"++GyERP.DriverNO, baseclass.DES.of_EncryStr_64(ls_password, "loginpasskey"));
                    MyConfig.of_SetMySysSet("Login", "logindate", DateTime.Now.ToString());
                    if (chk_login.Checked)//下次自动登录
                    {
                        MyConfig.of_SetMySysSet("Login", "Login", "Y");
                    }
                    else
                    {
                        MyConfig.of_SetMySysSet("Login", "Login", "N");
                    }
                    //登陆成功
                    int li_rowcount = MyConfig.ExecuteScalarNum("select count(*) from customer limit 1");

                    Toast.MakeText(this, "登陆成功", ToastLength.Short).Show();
                    Intent it = new Intent();
                    Bundle bu = new Bundle();
                    bu.PutString("name", "data");
                    bu.PutString("update", "");
                    it.PutExtras(bu);
                    if (li_rowcount <= 0)
                    {
                        it.SetClass(this.ApplicationContext, typeof(Loading));
                    }
                    else
                    {
                        it.SetClass(this.ApplicationContext, typeof(Index));
                    }
                    LocalYW.of_SetMySysSet("comname", "defaultcomname", GyERP.ComName);
                    LocalYW.of_SetMySysSet("comname", "defaultusername", ls_username);
                    ERPAddCols.of_AddCols();

                    StartActivity(it);
                    Finish();
                }
                #endregion
                else
                {
                    Toast.MakeText(this, "登陆失败,请检查用户名密码", ToastLength.Short).Show();
                    return;
                }
            };
            //刷新登陆数据
            Refresh.Click += delegate
            {
                baseclass.GyERP.of_YwInit();
                GyERP.of_Down_group_User(true);
                baseclass.GyERP.of_SetComName(GyERP.ComName);
                StartActivity(typeof(SplashScreen));
                Finish();
            };
            txt_msg.Click += delegate
            {
                if (as_date == null)
                    ai_clickNum++;
                else
                {
                    if (SysVisitor.DateDiff(as_date, SysVisitor.timeSpan.Milliseconds) < 300)
                    {
                        if (ai_clickNum == 3)
                        {
                            SysVisitor.GetVibrator(this);
                            StartActivity(typeof(TelePhoneManager));
                            Finish();
                        }
                        ai_clickNum++;
                    }
                    else
                    {
                        ai_clickNum = 0;
                    }
                }
                as_date = DateTime.Now;
            };
            ImageButton netType_del = FindViewById<ImageButton>(Resource.Id.Index_netType_del);
            LinearLayout netType_view = FindViewById<LinearLayout>(Resource.Id.Index_netType_LinearLayout);
            TextView netType = FindViewById<TextView>(Resource.Id.Index_netType_text);
            netType_del.Click += delegate { netType_view.Visibility = ViewStates.Gone; ab_shouNetType = true; };
            netType.Click += delegate
            {
                Intent intent = null;
                if (int.Parse(Android.OS.Build.VERSION.Sdk) > 10)
                {
                    intent = new Intent(Android.Provider.Settings.ActionWirelessSettings);
                }
                else
                {
                    intent = new Intent();
                    ComponentName component = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
                    intent.SetComponent(component);
                    intent.SetAction("android.intent.action.VIEW");
                }
                StartActivity(intent);
            };
            System.Threading.Thread thr = new System.Threading.Thread(new System.Threading.ThreadStart(of_netType));
            thr.Start();
        }
コード例 #47
0
        private void SetUpStationTo()
        {
            List<StationClass> stations = (List<StationClass>)dataProvider.GetOtherStationsForLine(spinnerLine.SelectedItem.ToString(), spinnerStationFrom.SelectedItem.ToString());

            ArrayAdapter<StationClass> adapter = new ArrayAdapter<StationClass>(this, Android.Resource.Layout.SimpleSpinnerItem);
            foreach (StationClass s in stations)
                adapter.Add(s.Name);
            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerStationTo.Adapter = adapter;

            if (loading)
            {
                var prefences = this.GetSharedPreferences("settings", FileCreationMode.Private);
                spinnerStationTo.SetSelection(prefences.GetInt("stationTo", 0));
            } else
            {
                spinnerStationTo.SetSelection(0);
            }
        }
コード例 #48
0
ファイル: Login.cs プロジェクト: eatage/GyAppMf
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Login);

            if (SysVisitor.getVersionCode(this) != -1)
            {
                _publicfuns.of_SetMySysSet("app", "vercode", SysVisitor.getVersionCode(this).ToString());
            }
            if (SysVisitor.getVersionName(this) != "")
            {
                _publicfuns.of_SetMySysSet("app", "vername", SysVisitor.getVersionName(this));
            }
            _publicfuns.of_SetMySysSet("phone", "meid", SysVisitor.MEID(this));
            #region 自动登录
            if (_publicfuns.of_GetMySysSet("Login", "Login") == "Y")
            {
                string ls_user = _publicfuns.of_GetMySysSet("Login", "username");
                string ls_pwd = _publicfuns.of_GetMySysSet("Login", "password");
                string ls_logindate = _publicfuns.of_GetMySysSet("Login", "logindate");
                if (!string.IsNullOrEmpty(ls_user) && !string.IsNullOrEmpty(ls_pwd))
                {
                    DateTime time;
                    try
                    {
                        time = Convert.ToDateTime(ls_logindate);
                    }
                    catch
                    {
                        time = DateTime.Now.AddDays(-100);
                    }
                    if (SysVisitor.DateDiff(time.ToString(), SysVisitor.timeSpan.Days) <= 7)
                    {
                        SysVisitor.UserName = ls_user;
                        Intent it = new Intent();
                        Bundle bu = new Bundle();
                        bu.PutString("name", "data");
                        bu.PutString("update", "");
                        it.PutExtras(bu);
                        it.SetClass(this.ApplicationContext, typeof(Index));
                        StartActivity(it);
                        Finish();
                        return;
                    }
                }
            }
            #endregion
            string ls_DeviceId = SysVisitor.MEID(this);

            #region 初始化控件
            spinner = FindViewById<Spinner>(Resource.Id.login_company);
            spinner_mygroup = FindViewById<Spinner>(Resource.Id.login_group);
            username = FindViewById<Spinner>(Resource.Id.login_username);
            btn_cancel = FindViewById<Button>(Resource.Id.login_cancel);
            btn_login = FindViewById<Button>(Resource.Id.login_submit);
            Refresh = FindViewById<TextView>(Resource.Id.login_Refresh);
            password = FindViewById<EditText>(Resource.Id.login_pass);
            chk_showpwd = FindViewById<CheckBox>(Resource.Id.login_showpwd);//显示密码
            chk_login = FindViewById<CheckBox>(Resource.Id.login_checklogin);//自动登录
            text = FindViewById<TextView>(Resource.Id.login_text);//底部说明文字
            #endregion

            int li_row = SqliteHelper.ExecuteNum("select count(*) from customer");
            if (li_row <= 0)
            {
                text.Text = "首次登陆时需要从服务器获取大量数据\n可能需要几分钟甚至更长时间\n建议在网络条件较好的环境下操作\n获取数据过程中请不要关闭程序";
            }
            string CompanyList = _publicfuns.of_GetMySysSet("Login", "CompanyList");
            string CompanyHost = _publicfuns.of_GetMySysSet("Login", "CompanyHost");
            //未获取到本地数据  从服务器获取
            if (string.IsNullOrEmpty(CompanyList) || string.IsNullOrEmpty(CompanyHost))
            {
                Intent it = new Intent();
                Bundle bu = new Bundle();
                bu.PutString("name", "login");
                it.PutExtras(bu);
                it.SetClass(this.ApplicationContext, typeof(Loading));
                StartActivity(it);
                Finish();
                return;
            }
            string[] list = { };
            if (CompanyList.Substring(0, 2) == "OK")
            {
                list = CompanyList.Substring(2).Split(',');
            }
            if (CompanyHost.Substring(0, 2) == "OK")
            {
                _publicfuns.of_SetMySysSet("Login", "CompanyHost", CompanyHost);
            }
            #region 为控件绑定数据
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < list.Length; i++)
            {
                adapter.Add(list[i]);
            }
            spinner.Adapter = adapter;
            spinner.SetSelection(list.Length - 1, true);//默认选中项

            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            DataTable ldt = new DataTable();
            ldt = SqliteHelper.ExecuteDataTable("select groupname from mygroup");
            for (int i = 0; i < ldt.Rows.Count; i++)
            {
                adapter.Add(ldt.Rows[i]["groupname"].ToString());
            }
            spinner_mygroup.Adapter = adapter;

            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            ldt = new DataTable();
            string ls_gid = "";
            ls_gid = SqliteHelper.ExecuteScalar("select gid from mygroup");
            ldt = SqliteHelper.ExecuteDataTable("select username from myuser where gid='" + ls_gid + "'");
            for (int i = 0; i < ldt.Rows.Count; i++)
            {
                adapter.Add(ldt.Rows[i]["username"].ToString());
            }
            username.Adapter = adapter;
            #endregion

            spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            spinner_mygroup.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(group_ItemSelected);

            chk_showpwd.CheckedChange += delegate
            {
                if (chk_showpwd.Checked)
                {
                    password.InputType = Android.Text.InputTypes.TextVariationWebEditText;
                }
                else
                {
                    password.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;
                }
                password.SetSelection(password.Text.Length);
            };

            btn_cancel.Click += delegate
            {
                SysVisitor.EXIT(this);
            };

            //登陆
            btn_login.Click += delegate
            {
                string local_user = _publicfuns.of_GetMySysSet("Login", "username");
                string local_pwd = _publicfuns.of_GetMySysSet("Login", "password");
                string local_logindate = _publicfuns.of_GetMySysSet("Login", "logindate");

                string ls_username = username.SelectedItem.ToString();
                string ls_password = password.Text;

                string ls_Login = "";
                DateTime time;
                try
                {
                    time = Convert.ToDateTime(local_logindate);
                }
                catch
                {
                    time = DateTime.Now.AddDays(-100);
                }
                #region 本地登陆
                if (SysVisitor.DateDiff(time.ToString(), SysVisitor.timeSpan.Days) <= 7)
                {
                    if (!string.IsNullOrEmpty(local_user) && !string.IsNullOrEmpty(local_pwd))
                    {
                        if (local_user == ls_username && local_pwd == baseclass.DES.of_EncryStr_64(ls_password, "loginpasskey"))
                        {
                            ls_Login = "******";//本地账号密码校验成功
                                            //测试时关闭本地校验
                        }
                    }
                }
                if (string.IsNullOrEmpty(ls_Login))//未完成本地登陆
                {
                    if (!SysVisitor.isNetworkConnected(this))
                    {
                        Toast.MakeText(this, "当前网络不可用,请检查你的网络设置", ToastLength.Short).Show();
                        return;
                    }
                    string ls_error = YW.of_GetCompanyList(ls_DeviceId);
                    if (ls_error.Substring(0, 2) != "OK")
                    {
                        //Toast.MakeText(this, "该手机未注册,请重新注册", ToastLength.Long).Show();
                        //return;
                        StartActivity(typeof(enroll));
                        Finish();
                        return;
                    }
                    YW.of_GetERPurl(SysVisitor.Get_Comname(), ls_DeviceId);
                    ls_error = YW.of_CheckNetWorkOK();
                    if (ls_error != "OK")
                    {
                        Toast.MakeText(this, "未能成功连接服务器,请重试", ToastLength.Short).Show();
                        return;
                    }
                    ls_Login = YW.Of_loginYW(SysVisitor.Get_Comname(), ls_username, ls_password);//登陆
                }
                #endregion
                //YW.SendMessage_MygroupUser_json();
                if (string.IsNullOrEmpty(ls_username) || string.IsNullOrEmpty(ls_password))
                {
                    Toast.MakeText(this, "用户名或密码不能为空", ToastLength.Short).Show();
                }
                #region 登陆成功
                if (ls_Login == "OK")
                {
                    _publicfuns.of_SetMySysSet("Login", "username", ls_username);
                    _publicfuns.of_SetMySysSet("Login", "password", baseclass.DES.of_EncryStr_64(ls_password, "loginpasskey"));
                    _publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.ToString());
                    if (chk_login.Checked)//下次自动登录
                    {
                        _publicfuns.of_SetMySysSet("Login", "Login", "Y");
                    }
                    else
                    {
                        _publicfuns.of_SetMySysSet("Login", "Login", "N");
                    }
                    //登陆成功
                    string ls_row = SqliteHelper.ExecuteScalar("select count(*) from customer_small");
                    int row = 0;
                    try
                    {
                        row = int.Parse(ls_row);
                    }
                    catch { }
                    Toast.MakeText(this, "登陆成功", ToastLength.Short).Show();
                    Intent it = new Intent();
                    Bundle bu = new Bundle();
                    bu.PutString("name", "data");
                    bu.PutString("update", "");
                    it.PutExtras(bu);
                    if (row <= 0)
                    {
                        it.SetClass(this.ApplicationContext, typeof(Loading));
                    }
                    else
                    {
                        it.SetClass(this.ApplicationContext, typeof(Index));
                    }
                    SysVisitor.UserName = ls_username;
                    StartActivity(it);
                    Finish();
                }
                #endregion
                else
                {
                    Toast.MakeText(this, "登陆失败,请检查用户名密码", ToastLength.Short).Show();
                }
            };

            //Android.Views.InputMethods.InputMethodManager imm = (Android.Views.InputMethods.InputMethodManager)GetSystemService(Context.InputMethodService);
            //imm.HideSoftInputFromWindow(btn_login.WindowToken, Android.Views.InputMethods.HideSoftInputFlags.None);
            //刷新登陆数据
            Refresh.Click += delegate
            {
                Intent it = new Intent();
                Bundle bu = new Bundle();
                bu.PutString("name", "login");
                it.PutExtras(bu);
                it.SetClass(this.ApplicationContext, typeof(Loading));
                StartActivity(it);
                Finish();
            };

            ImageButton netType_del = FindViewById<ImageButton>(Resource.Id.Index_netType_del);
            LinearLayout netType_view = FindViewById<LinearLayout>(Resource.Id.Index_netType_LinearLayout);
            TextView netType = FindViewById<TextView>(Resource.Id.Index_netType_text);
            netType_del.Click += delegate { netType_view.Visibility = ViewStates.Gone; ab_shouNetType = true; };
            netType.Click += delegate
            {
                Intent intent = null;
                if (int.Parse(Android.OS.Build.VERSION.Sdk) > 10)
                {
                    intent = new Intent(Android.Provider.Settings.ActionWirelessSettings);
                }
                else
                {
                    intent = new Intent();
                    ComponentName component = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
                    intent.SetComponent(component);
                    intent.SetAction("android.intent.action.VIEW");
                }
                StartActivity(intent);
            };
            System.Threading.Thread thr = new System.Threading.Thread(new System.Threading.ThreadStart(of_netType));
            thr.Start();
        }
コード例 #49
0
        private void SetUpLine()
        {
            List<LineClass> lines = (List<LineClass>)dataProvider.GetLines();

            ArrayAdapter<LineClass> adapter = new ArrayAdapter<LineClass>(this, Android.Resource.Layout.SimpleSpinnerItem);
            foreach (LineClass l in lines)
                adapter.Add(l.Name);
            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerLine.Adapter = adapter;

            if (loading)
            {
                var prefences = this.GetSharedPreferences("settings", FileCreationMode.Private);
                int herp = prefences.GetInt("line", 0);
                spinnerLine.SetSelection(herp);
            } else
            {
                spinnerLine.SetSelection(0);
            }

            if (loading)
                spinnerLine.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinnerLine_ItemSelected);
        }
コード例 #50
0
		protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			// Setup the window
			RequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
			SetContentView(R.Layout.device_list);

			// Set result CANCELED in case the user backs out
			SetResult(Activity.RESULT_CANCELED);

			// Initialize the button to perform device discovery
			var scanButton = (Button) FindViewById(R.Id.button_scan);
		    scanButton.Click += (s, x) => {
		        doDiscovery();
                ((View)s).SetVisibility(View.GONE);
		    };

			// Initialize array adapters. One for already paired devices and
			// one for newly discovered devices
			mPairedDevicesArrayAdapter = new ArrayAdapter<string>(this, R.Layout.device_name);
			mNewDevicesArrayAdapter = new ArrayAdapter<string>(this, R.Layout.device_name);

			// Find and set up the ListView for paired devices
			var pairedListView = (ListView) FindViewById(R.Id.paired_devices);
			pairedListView.Adapter = mPairedDevicesArrayAdapter;
		    pairedListView.ItemClick += OnDeviceClick;

			// Find and set up the ListView for newly discovered devices
			ListView newDevicesListView = (ListView) FindViewById(R.Id.new_devices);
			newDevicesListView.Adapter = mNewDevicesArrayAdapter;
			newDevicesListView.ItemClick += OnDeviceClick;

			// Register for broadcasts when a device is discovered
			IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
			this.RegisterReceiver(mReceiver, filter);

			// Register for broadcasts when discovery has finished
			filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
			this.RegisterReceiver(mReceiver, filter);

			// Get the local Bluetooth adapter
			mBtAdapter = BluetoothAdapter.GetDefaultAdapter();

			// Get a set of currently paired devices
			var pairedDevices = mBtAdapter.BondedDevices;

			// If there are paired devices, add each one to the ArrayAdapter
			if (pairedDevices.Size() > 0)
			{
				FindViewById(R.Id.title_paired_devices).Visibility = View.VISIBLE;
				foreach (BluetoothDevice device in pairedDevices.AsEnumerable())
				{
					mPairedDevicesArrayAdapter.Add(device.Name + "\n" + device.Address);
				}
			}
			else
			{
				string noDevices = Resources.GetText(R.String.none_paired).ToString();
				mPairedDevicesArrayAdapter.Add(noDevices);
			}
		}
コード例 #51
0
        private void handleSpinner()
        {
            var spinnerDistrict = FindViewById<Spinner> (Resource.Id.spinner_District);
            var spinnerWard = FindViewById<Spinner> (Resource.Id.spinner_Ward);
            var listAll = viewModel.DAL.GetAllDistrict ();
            ArrayList listNameDistrict = new ArrayList ();
            ArrayList listNameWard = new ArrayList ();
            var adapterDistrict = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < listAll.Count; i++) {
                adapterDistrict.Add (listAll [i].name);
            }

            spinnerDistrict.Adapter = adapterDistrict;
            spinnerDistrict.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                //district
                StringBuilder districtName = null;
                if (e.Position != 0) {
                    try {
                        bool checkDistrict = viewModel.GetDrugStoreByDistrict (listAll [e.Position].name.Trim (), null);
                        if (checkDistrict) {
                            mDrugstoreAdapter = new DrugStoreListViewAdapter (this, viewModel.list_drugstore);
                            listViewDrugStores.Adapter = mDrugstoreAdapter;
                        } else
                            listViewDrugStores.Adapter = null;
                    } catch (Exception ex) {
                    }
                }
                //ward
                var adapterWard = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
                int positionDistrict = e.Position;
                for (int i = 0; i < listAll [positionDistrict].WardChild.Count; i++) {
                    adapterWard.Add (listAll [positionDistrict].WardChild [i].name);
                }
                spinnerWard.Adapter = adapterWard;
                spinnerWard.ItemSelected += (object ow, AdapterView.ItemSelectedEventArgs ew) => {
                    if (ew.Position != 0) {
                        try {
                            bool checkWard = viewModel.GetDrugStoreByDistrict (listAll [e.Position].name.Trim (), listAll [positionDistrict].WardChild [ew.Position].name.Trim ());
                            if (checkWard) {
                                mDrugstoreAdapter = new DrugStoreListViewAdapter (this, viewModel.list_drugstore);
                                listViewDrugStores.Adapter = mDrugstoreAdapter;
                            } else
                                listViewDrugStores.Adapter = null;
                        } catch (Exception ex) {
                        }
                    }
                };
            };
        }
コード例 #52
0
        /// <summary>
        /// the method called when creating the activity
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

              SetContentView(Resource.Layout.SelectDevice);

              // create a list view and populate it with the devices
              ListView deviceListView = FindViewById<ListView>(Resource.SelectDevice.deviceListView);
              ArrayAdapter<Device> adapter = new ArrayAdapter<Device>(this, Android.Resource.Layout.SimpleListItem1);
              deviceListView.Adapter = adapter;
              deviceListView.ItemClick += new EventHandler<AdapterView.ItemClickEventArgs>(deviceSelected);

              // add hooks for adding and removing devices
              MyGPO.DeviceRemoved += delegate(Device theDevice) {
            RunOnUiThread(() => adapter.Remove(theDevice));
              };
              MyGPO.DeviceAdded += delegate(Device theDevice) {
            RunOnUiThread(() => adapter.Add(theDevice));
              };
        }
コード例 #53
0
ファイル: backmoneyrecord.cs プロジェクト: eatage/AppTest
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.backmoneyrecord);
            string ls_cus_code = SysVisitor.cus_code;
            TextView txt_cus_name = FindViewById<TextView>(Resource.Id.backmoneyrecord_cus_name);
            Spinner sp_subcom = FindViewById<Spinner>(Resource.Id.backmoneyrecord_subcom);
            Spinner sp_bank = FindViewById<Spinner>(Resource.Id.backmoneyrecord_bank);
            TextView txt_date = FindViewById<TextView>(Resource.Id.backmoneyrecord_date);
            Spinner sp_type = FindViewById<Spinner>(Resource.Id.backmoneyrecord_moneytype);
            TextView txt_money = FindViewById<TextView>(Resource.Id.backmoneyrecord_money);
            TextView txt_memo = FindViewById<TextView>(Resource.Id.backmoneyrecord_memo);
            CheckBox chk_memo = FindViewById<CheckBox>(Resource.Id.backmoneyrecord_iscustomer);
            TextView txt_fee = FindViewById<TextView>(Resource.Id.backmoneyrecord_Counter_fee);
            Button save = FindViewById<Button>(Resource.Id.backmoneyrecord_submit);
            CheckBox iscustomer = FindViewById<CheckBox>(Resource.Id.backmoneyrecord_iscustomer);
            TextView txt_give_money = FindViewById<TextView>(Resource.Id.backmoneyrecord_give_money);
            LinearLayout IBtn_back = FindViewById<LinearLayout>(Resource.Id.backmoneyrecord_cancel);
            Button sel_username= FindViewById<Button>(Resource.Id.backmoneyrecord_check_username);

            sel_username.Click += delegate 
            {
                Intent intent = new Intent();
                Bundle bu = new Bundle();
                bu.PutString("name", "backmoneyrecord");
                intent.PutExtras(bu);
                intent.SetClass(this, typeof(Customer));
                StartActivity(intent);
            };

            IBtn_back.Click += delegate 
            {
                OnBackPressed();
                //StartActivity(typeof(Index));
            };
            #region 设置客户
            if (!string.IsNullOrEmpty(ls_cus_code))
            {
                txt_cus_name.Text = SysVisitor.cus_name;
            }
            txt_cus_name.FocusChange += delegate 
            {
                if (!txt_cus_name.HasFocus)
                {
                    if (txt_cus_name.Text != "")
                    {
                        string sql = "select cus_code from customer where cus_name = '" + txt_cus_name.Text + "'";
                        ls_cus_code = SqliteHelper.ExecuteScalar(sql);
                        if (string.IsNullOrEmpty(ls_cus_code))
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(this);
                            builder.SetTitle("提示:");
                            builder.SetMessage("输入的客户不存在");
                            builder.SetNegativeButton("确定", delegate { });
                            builder.Show();
                            txt_cus_name.Text = "";
                            SysVisitor.cus_code = "";
                            return;
                        }
                        SysVisitor.cus_code = ls_cus_code;
                    }
                    else
                    {
                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        builder.SetTitle("提示:");
                        builder.SetMessage("客户名称不能为空");
                        builder.SetNegativeButton("确定", delegate { });
                        builder.Show();
                        SysVisitor.cus_code = "";
                        return;
                    }
                }
            };
            #endregion
            #region 为控件绑定数据
            txt_date.Text = DateTime.Now.ToString("yyyy-MM-dd");

            DataTable ldt_subcom = new DataTable();
            ldt_subcom = SqliteHelper.ExecuteDataTable("select comname FROM subcom");
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < ldt_subcom.Rows.Count; i++)
            {
                adapter.Add(ldt_subcom.Rows[i]["comname"].ToString());
            }
            sp_subcom.Adapter = adapter;

            DataTable ldt_type = new DataTable();
            ldt_type = SqliteHelper.ExecuteDataTable("select accname FROM accsubject where oneaccno like '101%'");
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < ldt_type.Rows.Count; i++)
            {
                adapter.Add(ldt_type.Rows[i]["accname"].ToString());
            }
            sp_bank.Adapter = adapter;

            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            adapter.Add("现金");
            adapter.Add("银行");
            sp_type.Adapter = adapter;
            #endregion

            sp_type.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(sp_type_ItemSelected);
            save.Click += delegate 
            {
                if (string.IsNullOrEmpty(SysVisitor.cus_code))
                {
                    Toast.MakeText(this, "请先选择客户", ToastLength.Long).Show();
                    return;
                }
                #region 获取值
                string ls_cusname = txt_cus_name.Text;
                string ls_date = txt_date.Text;
                string ls_money = txt_money.Text;
                string ls_memo = txt_memo.Text;
                bool lb_fee = iscustomer.Checked;
                string ls_fee = txt_fee.Text;
                string ls_subcom = as_subcom;
                string ls_bank = as_bank;
                string ls_type = as_type;
                string ls_give = txt_give_money.Text;
                as_bank = sp_bank.SelectedItem.ToString();
                as_subcom = sp_subcom.SelectedItem.ToString();
                as_type = sp_type.SelectedItem.ToString();
                #endregion
                #region 判断条件
                if (ls_type == "现金/银行")
                {
                    Toast.MakeText(this, "请选择汇款方式", ToastLength.Long).Show();
                    return;
                }
                if (ls_date.Length < 8)
                {
                    Toast.MakeText(this, "日期格式不对", ToastLength.Long).Show();
                    return;
                }
                if (ls_date.Split('-').Length != 3)
                {
                    Toast.MakeText(this, "日期格式不对", ToastLength.Long).Show();
                    return;
                }
                if (string.IsNullOrEmpty(ls_money))
                {
                    Toast.MakeText(this, "请输入汇款金额", ToastLength.Long).Show();
                    return;
                }
                #endregion
                string bankmoneyno = SqliteHelper.ExecuteScalar("select accno FROM accsubject where accname ='" + ls_bank + "'");
                string ls_subcom_id= SqliteHelper.ExecuteScalar("select subNo FROM subcom where comname='" + ls_subcom + "'");
                string ls_id = Guid.NewGuid().ToString("N");
                n_create_sql lnv_sql = new n_create_sql();
                lnv_sql.of_SetTable("backmoneyrecord");
                lnv_sql.of_AddCol("recordno", ls_id);
                lnv_sql.of_AddCol("insdate", DateTime.Now.ToString("yyyy-MM-dd"));
                lnv_sql.of_AddCol("human", SysVisitor.UserName);
                lnv_sql.of_AddCol("cus_code", ls_cus_code);
                lnv_sql.of_AddCol("money", ls_money);
                lnv_sql.of_AddCol("subcom", ls_subcom_id);
                lnv_sql.of_AddCol("checkman", SysVisitor.UserName);
                lnv_sql.of_AddCol("checkdate", ls_date);
                lnv_sql.of_AddCol("bankmoneyno", ls_id);
                lnv_sql.of_AddCol("memo", ls_memo);
                lnv_sql.of_AddCol("bank", bankmoneyno);
                lnv_sql.of_AddCol("GiftMoney", ls_give);
                lnv_sql.of_AddCol("isupdate", "N");
                lnv_sql.of_execute();
                Toast.MakeText(this, "保存成功", ToastLength.Long).Show();
                System.Threading.Thread.Sleep(500);
                Intent it = new Intent();
                it.SetClass(this.ApplicationContext, typeof(Index));
                StartActivity(it);
            };
        }
コード例 #54
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Setup the window
            RequestWindowFeature (WindowFeatures.IndeterminateProgress);
            SetContentView (Resource.Layout.device_list);

            // Set result CANCELED incase the user backs out
            SetResult (Result.Canceled);

            // Initialize the button to perform device discovery
            var scanButton = FindViewById<Button> (Resource.Id.button_scan);
            scanButton.Click += (sender, e) => {
                DoDiscovery ();
                (sender as View).Visibility = ViewStates.Gone;
            };

            // Initialize array adapters. One for already paired devices and
            // one for newly discovered devices
            pairedDevicesArrayAdapter = new ArrayAdapter<string> (this, Resource.Layout.device_name);
            newDevicesArrayAdapter = new ArrayAdapter<string> (this, Resource.Layout.device_name);

            // Find and set up the ListView for paired devices
            var pairedListView = FindViewById<ListView> (Resource.Id.paired_devices);
            pairedListView.Adapter = pairedDevicesArrayAdapter;
            pairedListView.ItemClick += DeviceListClick;

            // Find and set up the ListView for newly discovered devices
            var newDevicesListView = FindViewById<ListView> (Resource.Id.new_devices);
            newDevicesListView.Adapter = newDevicesArrayAdapter;
            newDevicesListView.ItemClick += DeviceListClick;

            // Register for broadcasts when a device is discovered
            receiver = new Receiver (this);
            var filter = new IntentFilter (BluetoothDevice.ActionFound);
            RegisterReceiver (receiver, filter);

            // Register for broadcasts when discovery has finished
            filter = new IntentFilter (BluetoothAdapter.ActionDiscoveryFinished);
            RegisterReceiver (receiver, filter);

            // Get the local Bluetooth adapter
            btAdapter = BluetoothAdapter.DefaultAdapter;

            // Get a set of currently paired devices
            var pairedDevices = btAdapter.BondedDevices;

            // If there are paired devices, add each one to the ArrayAdapter
            if (pairedDevices.Count > 0) {
                FindViewById<View> (Resource.Id.title_paired_devices).Visibility = ViewStates.Visible;
                foreach (var device in pairedDevices) {
                    pairedDevicesArrayAdapter.Add (device.Name + "\n" + device.Address);
                }
            } else {
                String noDevices = Resources.GetText (Resource.String.none_paired);
                pairedDevicesArrayAdapter.Add (noDevices);
            }
        }
コード例 #55
0
			public override void OnActivityCreated (Bundle savedInstanceState)
			{
				base.OnActivityCreated (savedInstanceState);
				brickController = BrickController.Instance;
				remoteSettings = RemoteSettings.Instance;
				
				sensorSpinner[0] = this.View.FindViewById<Spinner> (Resource.Id.sensorSpinner1);
				sensorSpinner[1] = this.View.FindViewById<Spinner> (Resource.Id.sensorSpinner2);
				sensorSpinner[2] = this.View.FindViewById<Spinner> (Resource.Id.sensorSpinner3);
				sensorSpinner[3] = this.View.FindViewById<Spinner> (Resource.Id.sensorSpinner4);
			
				sensorReadButton[0] = this.View.FindViewById<Button> (Resource.Id.readButton1);
				sensorReadButton[1] = this.View.FindViewById<Button> (Resource.Id.readButton2);
				sensorReadButton[2] = this.View.FindViewById<Button> (Resource.Id.readButton3);
				sensorReadButton[3] = this.View.FindViewById<Button> (Resource.Id.readButton4);
			
				sensorSayButton[0] = this.View.FindViewById<Button> (Resource.Id.sayButton1);
				sensorSayButton[1] = this.View.FindViewById<Button> (Resource.Id.sayButton2);
				sensorSayButton[2] = this.View.FindViewById<Button> (Resource.Id.sayButton3);
				sensorSayButton[3] = this.View.FindViewById<Button> (Resource.Id.sayButton4);
			
				sensorValue[0] = this.View.FindViewById<EditText> (Resource.Id.sensorValue1);
				sensorValue[1] = this.View.FindViewById<EditText> (Resource.Id.sensorValue2);
				sensorValue[2] = this.View.FindViewById<EditText> (Resource.Id.sensorValue3);
				sensorValue[3] = this.View.FindViewById<EditText> (Resource.Id.sensorValue4);
			
			
				ArrayAdapter<string> adapter = new ArrayAdapter<string>(this.Activity,Android.Resource.Layout.SimpleSpinnerItem);
				string[] sensorNames = MonoBrick.NXT.Sensor.SensorDictionary.Keys.ToArray();
				foreach(string s in sensorNames){
					adapter.Add(s);
				}
				for(int i = 0; i < 4; i ++){
					sensorSpinner[i].Adapter = adapter;
				}
				sensorReadButton[0].Click += delegate {
					brickController.SpawnThread(delegate(){
						string s = brickController.NXT.Sensor1.ReadAsString();
						Activity.RunOnUiThread(delegate() {
							sensorValue[0].Text = s;
						});
					});
				};
			
				sensorReadButton[1].Click += delegate {
					brickController.SpawnThread(delegate(){
						string s = brickController.NXT.Sensor2.ReadAsString();
						Activity.RunOnUiThread(delegate() {
							sensorValue[1].Text = s;
						});
					});
				};
			
				sensorReadButton[2].Click += delegate {
					brickController.SpawnThread(delegate(){
						string s = brickController.NXT.Sensor3.ReadAsString();
						Activity.RunOnUiThread(delegate() {
							sensorValue[2].Text = s;
						});
					});
				};
			
				sensorReadButton[3].Click += delegate {
					brickController.SpawnThread(delegate(){
						string s = brickController.NXT.Sensor4.ReadAsString();
						Activity.RunOnUiThread(delegate() {
							sensorValue[3].Text = s;
						});
					});
				};
				
				sensorSayButton[0].Click += delegate {
					brickController.SpawnThread(delegate(){
						string s = brickController.NXT.Sensor1.ReadAsString();
						Activity.RunOnUiThread(delegate() {
							sensorValue[0].Text = s;
							//this should not run in the gui thread
							if(remoteSettings.SensorValueToSpeech && TabActivity.Speech != null){
								TabActivity.Speech.Speak(s, Android.Speech.Tts.QueueMode.Flush, null);
							}
						});
						
					});
				};
				
				
				sensorSayButton[1].Click += delegate {
					brickController.SpawnThread(delegate(){
						string s = brickController.NXT.Sensor2.ReadAsString();
						Activity.RunOnUiThread(delegate() {
							sensorValue[1].Text = s;
							//this should not run in the gui thread
							if(remoteSettings.SensorValueToSpeech && TabActivity.Speech != null){
								TabActivity.Speech.Speak(s, Android.Speech.Tts.QueueMode.Flush, null);
							}
						});
						
					});
				};
				
				
				sensorSayButton[2].Click += delegate {
					brickController.SpawnThread(delegate(){
						string s = brickController.NXT.Sensor3.ReadAsString();
						Activity.RunOnUiThread(delegate() {
							sensorValue[2].Text = s;
							//this should not run in the gui thread
							if(remoteSettings.SensorValueToSpeech && TabActivity.Speech != null){
								TabActivity.Speech.Speak(s, Android.Speech.Tts.QueueMode.Flush, null);
							}
						});
						
					});
				};
				
				sensorSayButton[3].Click += delegate {
					brickController.SpawnThread(delegate(){
						string s = brickController.NXT.Sensor4.ReadAsString();
						Activity.RunOnUiThread(delegate() {
							sensorValue[3].Text = s;
							//this should not run in the gui thread
							if(remoteSettings.SensorValueToSpeech && TabActivity.Speech != null){
								TabActivity.Speech.Speak(s, Android.Speech.Tts.QueueMode.Flush, null);
							}
						});
						
					});
				};
			
				sensorSpinner[0].Id = 0;
				sensorSpinner[0].ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e) {
					Spinner spinner = (Spinner)sender;
	    			MonoBrick.NXT.Sensor newSensor = MonoBrick.NXT.Sensor.SensorDictionary[(string) spinner.GetItemAtPosition(e.Position)];
					remoteSettings.Sensor1 = (string) spinner.GetItemAtPosition(e.Position);
					brickController.SpawnThread(delegate(){
						brickController.NXT.Sensor1 = newSensor;
					});
				};
			
				sensorSpinner[1].Id = 0;
				sensorSpinner[1].ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e) {
					Spinner spinner = (Spinner)sender;
	    			MonoBrick.NXT.Sensor newSensor = MonoBrick.NXT.Sensor.SensorDictionary[(string) spinner.GetItemAtPosition(e.Position)];
					remoteSettings.Sensor2 = (string) spinner.GetItemAtPosition(e.Position);
					brickController.SpawnThread(delegate(){
						brickController.NXT.Sensor2 = newSensor;
					});
				};
			
				sensorSpinner[2].Id = 0;
				sensorSpinner[2].ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e) {
					Spinner spinner = (Spinner)sender;
	    			MonoBrick.NXT.Sensor newSensor = MonoBrick.NXT.Sensor.SensorDictionary[(string) spinner.GetItemAtPosition(e.Position)];
					remoteSettings.Sensor3 = (string) spinner.GetItemAtPosition(e.Position);
					brickController.SpawnThread(delegate(){
						brickController.NXT.Sensor3 = newSensor;
					});
				};
			
				sensorSpinner[3].Id = 0;
				sensorSpinner[3].ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e) {
					Spinner spinner = (Spinner)sender;
	    			MonoBrick.NXT.Sensor newSensor = MonoBrick.NXT.Sensor.SensorDictionary[(string) spinner.GetItemAtPosition(e.Position)];
					remoteSettings.Sensor4 = (string) spinner.GetItemAtPosition(e.Position);
					brickController.SpawnThread(delegate(){
						brickController.NXT.Sensor4 = newSensor;
					});
				};
				
			}