当前位置: 首页>>代码示例>>C#>>正文


C# ImageButton.SetOnTouchListener方法代码示例

本文整理汇总了C#中ImageButton.SetOnTouchListener方法的典型用法代码示例。如果您正苦于以下问题:C# ImageButton.SetOnTouchListener方法的具体用法?C# ImageButton.SetOnTouchListener怎么用?C# ImageButton.SetOnTouchListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageButton的用法示例。


在下文中一共展示了ImageButton.SetOnTouchListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.exDragGame);

            _myButton = FindViewById<ImageButton>(Resource.Id.exPhone);
            _myButton.SetOnTouchListener(this);
        }
开发者ID:kbyang,项目名称:PhoneApp,代码行数:9,代码来源:exDragGame.cs

示例2: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            Console.WriteLine("LockScreenActivity - OnCreate");
            base.OnCreate(bundle);

            _playerService = Bootstrapper.GetContainer().Resolve<IPlayerService>();
            _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();

            // Create bitmap cache
            int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024);
            int cacheSize = maxMemory / 16;
            _bitmapCache = new BitmapCache(null, cacheSize, 800, 800);

            // Create layout and get controls
            _navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
            SetContentView(Resource.Layout.LockScreen);
            _lblArtistName = FindViewById<TextView>(Resource.Id.lockScreen_lblArtistName);
            _lblAlbumTitle = FindViewById<TextView>(Resource.Id.lockScreen_lblAlbumTitle);
            _lblSongTitle = FindViewById<TextView>(Resource.Id.lockScreen_lblSongTitle);
            _lblPosition = FindViewById<TextView>(Resource.Id.lockScreen_lblPosition);
            _lblLength = FindViewById<TextView>(Resource.Id.lockScreen_lblLength);
            _btnPrevious = FindViewById<ImageButton>(Resource.Id.lockScreen_btnPrevious);
            _btnPlayPause = FindViewById<ImageButton>(Resource.Id.lockScreen_btnPlayPause);
            _btnNext = FindViewById<ImageButton>(Resource.Id.lockScreen_btnNext);
            _btnShuffle = FindViewById<ImageButton>(Resource.Id.lockScreen_btnShuffle);
            _btnRepeat = FindViewById<ImageButton>(Resource.Id.lockScreen_btnRepeat);
            _btnClose = FindViewById<ImageButton>(Resource.Id.lockScreen_btnClose);
            _btnClose.SetOnTouchListener(this);
            _btnPlayPause.SetOnTouchListener(this);
            _btnPrevious.SetOnTouchListener(this);
            _btnNext.SetOnTouchListener(this);
            _btnRepeat.SetOnTouchListener(this);
            _btnShuffle.SetOnTouchListener(this);

            _imageAlbum = FindViewById<ImageView>(Resource.Id.lockScreen_imageAlbum);
            _seekBar = FindViewById<SeekBar>(Resource.Id.lockScreen_seekBar);
            _seekBar.StartTrackingTouch += SeekBarOnStartTrackingTouch;
            _seekBar.StopTrackingTouch += SeekBarOnStopTrackingTouch;
            _seekBar.ProgressChanged += SeekBarOnProgressChanged;

            _btnClose.Click += (sender, args) => Finish();
            _btnPrevious.Click += (sender, args) => OnPlayerPrevious();
            _btnPlayPause.Click += (sender, args) => OnPlayerPlayPause();
            _btnNext.Click += (sender, args) => OnPlayerNext();
            _btnShuffle.Click += (sender, args) => OnPlayerShuffle();
            _btnRepeat.Click += (sender, args) => OnPlayerRepeat();
            //_btnPlaylist.Click += (sender, args) => {
            //    Intent intent = new Intent(this, typeof (PlaylistActivity));
            //    intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            //    StartActivity(intent);
            //};

            _timerSongPosition = new Timer();
            _timerSongPosition.Interval = 100;
            _timerSongPosition.Elapsed += (sender, args) => {
                if (_isPositionChanging)
                    return;

                RunOnUiThread(() => {
                    try
                    {
                        var position = _playerService.GetPosition();
                        //Console.WriteLine("LockScreenActivity - timerSongPosition - position: {0}", position);
                        _lblPosition.Text = position.Position;
                        float percentage = ((float)position.PositionBytes / (float)_playerService.CurrentPlaylistItem.LengthBytes) * 10000f;
                        _seekBar.Progress = (int)percentage;
                    }
                    catch
                    {
                        // Just ignore exception. It's not really worth it to start/stop the timer when the player is playing.
                        // TODO: In fact reuse the last position instead of returning 0.
                        _lblPosition.Text = "0:00.000";
                        _seekBar.Progress = 0;
                    }
                });
            };
            _timerSongPosition.Start();

            // Since the onViewReady action could not be added to an intent, tell the NavMgr the view is ready
            ((AndroidNavigationManager)_navigationManager).SetLockScreenActivityInstance(this);
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:81,代码来源:LockScreenActivity.cs

示例3: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            Console.WriteLine("MainActivity - OnCreate");
            base.OnCreate(bundle);

            _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();
            _messengerHub.Subscribe<MobileLibraryBrowserItemClickedMessage>(MobileLibraryBrowserItemClickedMessageReceived);

            RequestWindowFeature(WindowFeatures.ActionBar);
            SetContentView(Resource.Layout.Main);
            _actionBarSpinnerAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.action_list, Resource.Layout.actionbar_spinner_item);
            ActionBar.NavigationMode = ActionBarNavigationMode.List;
            ActionBar.Title = string.Empty;
            ActionBar.SetListNavigationCallbacks(_actionBarSpinnerAdapter, this);
            ActionBar.SetSelectedNavigationItem(1);

            _viewFlipper = FindViewById<ViewFlipper>(Resource.Id.main_viewflipper);
            _miniPlayer = FindViewById<LinearLayout>(Resource.Id.main_miniplayer);
            _miniPlaylist = FindViewById<LinearLayout>(Resource.Id.main_miniplaylist);
            _lblArtistName = FindViewById<TextView>(Resource.Id.main_miniplayer_lblArtistName);
            _lblAlbumTitle = FindViewById<TextView>(Resource.Id.main_miniplayer_lblAlbumTitle);
            _lblSongTitle = FindViewById<TextView>(Resource.Id.main_miniplayer_lblSongTitle);
            //_lblNextArtistName = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextArtistName);
            //_lblNextAlbumTitle = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextAlbumTitle);
            //_lblNextSongTitle = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextSongTitle);
            _lblPlaylistCount = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblPlaylistCount);
            _btnPrevious = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnPrevious);
            _btnPlayPause = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnPlayPause);
            _btnNext = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnNext);
            _btnPlaylist = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnPlaylist);
            _btnShuffle = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnShuffle);
            _btnRepeat = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnRepeat);
            _btnLeft = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnLeft);
            _cboPlaylist = FindViewById<Spinner>(Resource.Id.main_miniplaylist_cboPlaylist);
            _btnRight = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnRight);
            _imageAlbum = FindViewById<SquareImageView>(Resource.Id.main_miniplayer_imageAlbum);
            _miniPlayer.Click += (sender, args) => _messengerHub.PublishAsync<MobileNavigationManagerCommandMessage>(new MobileNavigationManagerCommandMessage(this, MobileNavigationManagerCommandMessageType.ShowPlayerView));
            _btnLeft.SetOnTouchListener(this);
            _btnRight.SetOnTouchListener(this);
            _btnPrevious.SetOnTouchListener(this);
            _btnPlayPause.SetOnTouchListener(this);
            _btnNext.SetOnTouchListener(this);
            _btnPlaylist.SetOnTouchListener(this);
            _btnShuffle.SetOnTouchListener(this);
            _btnRepeat.SetOnTouchListener(this);
            _btnPrevious.Click += (sender, args) => OnPlayerPrevious();
            _btnPlayPause.Click += (sender, args) => OnPlayerPlayPause();
            _btnNext.Click += (sender, args) => OnPlayerNext();
            _btnPlaylist.Click += (sender, args) => OnOpenPlaylist();
            _btnShuffle.Click += (sender, args) => OnPlayerShuffle();
            _btnRepeat.Click += (sender, args) => OnPlayerRepeat();
            _btnLeft.Click += BtnLeftOnClick;
            _btnRight.Click += BtnRightOnClick;

            // Set initial view flipper item
            int realIndex = _viewFlipper.IndexOfChild(_miniPlayer);
            _viewFlipper.DisplayedChild = realIndex;

            // Create bitmap cache
            Point size = new Point();
            WindowManager.DefaultDisplay.GetSize(size);
            int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024);
            int cacheSize = maxMemory / 16;
            BitmapCache = new BitmapCache(this, cacheSize, size.X / 6, size.X / 6);

            _playlistSpinnerAdapter = new ArrayAdapter<string>(this, Resource.Layout.playlist_spinner_item, new string[2] {"Hello", "World"});
            _cboPlaylist.Adapter = _playlistSpinnerAdapter;
            _cboPlaylist.ItemSelected += CboPlaylistOnItemSelected;

            Console.WriteLine("MainActivity - OnCreate - Binding presenters...");
            var navigationManager = (AndroidNavigationManager)Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
            navigationManager.MainActivity = this; // Watch out, this can lead to memory leaks!
            navigationManager.BindOptionsMenuView(this);
            navigationManager.BindPlayerStatusView(this);
            navigationManager.BindMobileMainView(this);
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:76,代码来源:MainActivity.cs

示例4: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            Console.WriteLine("PlayerActivity - OnCreate");

            _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>(); 
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Player);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            _navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
            _fragments = new List<Fragment>();
            _viewPager = FindViewById<ViewPager>(Resource.Id.player_pager);
            _viewPager.OffscreenPageLimit = 4;
            _viewPagerAdapter = new ViewPagerAdapter(FragmentManager, _fragments, _viewPager);
            _viewPagerAdapter.OnPageChanged += ViewPagerAdapterOnOnPageChanged;
            _viewPager.Adapter = _viewPagerAdapter;
            _viewPager.SetOnPageChangeListener(_viewPagerAdapter);

            _waveFormScrollView = FindViewById<WaveFormScrollView>(Resource.Id.player_waveFormScrollView);
            _imageViewAlbumArt = FindViewById<SquareImageView>(Resource.Id.player_imageViewAlbumArt);
            _lblPosition = FindViewById<TextView>(Resource.Id.player_lblPosition);
            _lblLength = FindViewById<TextView>(Resource.Id.player_lblLength);
            _btnPlayPause = FindViewById<ImageButton>(Resource.Id.player_btnPlayPause);
            _btnPrevious = FindViewById<ImageButton>(Resource.Id.player_btnPrevious);
            _btnNext = FindViewById<ImageButton>(Resource.Id.player_btnNext);
            _btnShuffle = FindViewById<ImageButton>(Resource.Id.player_btnShuffle);
            _btnRepeat = FindViewById<ImageButton>(Resource.Id.player_btnRepeat);
            _btnPlaylist = FindViewById<ImageButton>(Resource.Id.player_btnPlaylist);
            _seekBar = FindViewById<SeekBar>(Resource.Id.player_seekBar);
            _carrouselDot1 = FindViewById<Button>(Resource.Id.player_carrouselDot1);
            _carrouselDot2 = FindViewById<Button>(Resource.Id.player_carrouselDot2);
            _carrouselDot3 = FindViewById<Button>(Resource.Id.player_carrouselDot3);
            _carrouselDot4 = FindViewById<Button>(Resource.Id.player_carrouselDot4);
            _carrouselDot5 = FindViewById<Button>(Resource.Id.player_carrouselDot5);
            _btnPlayPause.Click += BtnPlayPauseOnClick;            
            _btnPrevious.Click += BtnPreviousOnClick;
            _btnNext.Click += BtnNextOnClick;
            _btnPlaylist.Click += BtnPlaylistOnClick;
            _btnRepeat.Click += BtnRepeatOnClick;
            _btnShuffle.Click += BtnShuffleOnClick;
            _btnPlayPause.SetOnTouchListener(this);
            _btnPrevious.SetOnTouchListener(this);
            _btnNext.SetOnTouchListener(this);
            _btnPlaylist.SetOnTouchListener(this);
            _btnRepeat.SetOnTouchListener(this);
            _btnShuffle.SetOnTouchListener(this);
            _seekBar.StartTrackingTouch += SeekBarOnStartTrackingTouch;
            _seekBar.StopTrackingTouch += SeekBarOnStopTrackingTouch;
            _seekBar.ProgressChanged += SeekBarOnProgressChanged;

            // Get screen size
            Point size = new Point();
            WindowManager.DefaultDisplay.GetSize(size);

            // Create bitmap cache
            int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024);
            int cacheSize = maxMemory / 12;
            _bitmapCache = new BitmapCache(this, cacheSize, size.X, size.X); // The album art takes the whole screen width

            // Match height with width (cannot do that in xml)
            //_imageViewAlbumArt.LayoutParameters = new ViewGroup.LayoutParams(_imageViewAlbumArt.Width, _imageViewAlbumArt.Width);

            if (bundle != null)
            {
                string state = bundle.GetString("key", "value");
                Console.WriteLine("PlayerActivity - OnCreate - State is {0} - isInitialized: {1}", state, _isInitialized);
            }
            else
            {

                Console.WriteLine("PlayerActivity - OnCreate - State is null - isInitialized: {0}", _isInitialized);
            }

            // Don't try to check the bundle contents, if the activity wasn't destroyed, it will be null.
            //if (bundle != null)
            //    Console.WriteLine("PlayerActivity - OnCreate - Bundle isn't null - value: {0}", bundle.GetString("key", "null"));
            //else
            //    Console.WriteLine("PlayerActivity - OnCreate - Bundle is null!");

            // When Android stops an activity, it recalls OnCreate after, even though the activity is not destroyed (OnDestroy). It actually goes through creating a new object (the ctor is called).
            //((AndroidNavigationManager)_navigationManager).SetPlayerActivityInstance(this);
            _navigationManager.BindPlayerView(MobileNavigationTabType.Playlists, this);

            // Activate lock screen if not already activated
            _messengerHub.PublishAsync<ActivateLockScreenMessage>(new ActivateLockScreenMessage(this, true));

            _messengerHub.Subscribe<ApplicationCloseMessage>(message =>
            {
                Console.WriteLine("PlayerActivity - Received ApplicationCloseMessage; closing activity of type {0}", this.GetType().FullName);
            });

        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:94,代码来源:PlayerActivity.cs


注:本文中的ImageButton.SetOnTouchListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。