示例#1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            //Permission取得
            const string permission = Manifest.Permission.WriteExternalStorage;
            int          flag       = 0;

            if (CheckSelfPermission(permission) == Permission.Denied)
            {
                ActivityCompat.RequestPermissions(this, new[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.Camera, Manifest.Permission.ReadExternalStorage }, 0);
            }

            //初期化
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);


            if (CheckSelfPermission(permission) == Permission.Granted)
            {
                Getfromdb();
            }

            // Get our RecyclerView layout:
            mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            //............................................................
            // Layout Manager Setup:

            // Use the built-in linear layout manager:
            mLayoutManager = new LinearLayoutManager(this);

            // Or use the built-in grid layout manager (two horizontal rows):
            // mLayoutManager = new GridLayoutManager

            // Plug the layout manager into the RecyclerView:
            mRecyclerView.SetLayoutManager(mLayoutManager);
            //............................................................
            // Adapter Setup:

            // Create an adapter for the RecyclerView, and pass it the
            // data set (the photo album) to manage:
            mAdapter = new PhotoAlbumAdapter(mPhotoAlbum);


            // Plug the adapter into the RecyclerView:
            mRecyclerView.SetAdapter(mAdapter);

            ItemTouchHelper itemTouchHelper = new
                                              ItemTouchHelper(new SwipeToDeleteCallback(mAdapter));

            itemTouchHelper.AttachToRecyclerView(mRecyclerView);

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

            //floatingactionButton実装
            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += delegate {
                Intent intent = new Intent(this, typeof(App4.plan_main));
                StartActivity(intent);
            };

            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);
        }
 public SwipeToDeleteCallback(PhotoAlbumAdapter adapter) : base(0, ItemTouchHelper.Left | ItemTouchHelper.Right)
 {
     mAdapter = adapter;
 }