Java 类android.support.design.widget.FloatingActionButton 实例源码

项目:android_firebase_green_thumb    文件:PlantDetailActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle("");
    mItemDescription = (TextView) findViewById(R.id.text_view_item_description);
    mItemPrice = (TextView) findViewById(R.id.text_view_item_price);
    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

    setSupportActionBar(mToolbar);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(true);
    }
    fab.setOnClickListener(this);

    mItemId = getIntent().getIntExtra(INTENT_EXTRA_ITEM, 0);

    getSupportLoaderManager().initLoader(PLANT_DETAIL_LOADER, null, this);
}
项目:circle-menu-android    文件:CircleMenuView.java   
private void initButtons(@NonNull Context context, @NonNull List<Integer> icons, @NonNull List<Integer> colors) {
    final int buttonsCount = Math.min(icons.size(), colors.size());
    for (int i = 0; i < buttonsCount; i++) {
        final FloatingActionButton button = new FloatingActionButton(context);
        button.setImageResource(icons.get(i));
        button.setBackgroundTintList(ColorStateList.valueOf(colors.get(i)));
        button.setClickable(true);
        button.setOnClickListener(new OnButtonClickListener());
        button.setOnLongClickListener(new OnButtonLongClickListener());
        button.setScaleX(0);
        button.setScaleY(0);
        button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        addView(button);
        mButtons.add(button);
    }
}
项目:BrewBook    文件:MapsActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);


    go = (Button) findViewById(R.id.button2);
    go.setOnClickListener(btGo);
    location = (EditText) findViewById(R.id.editLocation);
    progressBarSubject = (ProgressBar) findViewById(R.id.progressBar);
    SubjectListView = (ListView) findViewById(R.id.listview1);
    trendingBtm = (ImageButton) findViewById(R.id.imageBtmtrending);
    userBtm = (ImageButton) findViewById(R.id.imageBtmuser);
    locationBtm = (ImageButton) findViewById(R.id.imageBtmlocation);
    settingsBtm = (ImageButton) findViewById(R.id.imageBtmSettings);
    addReviewBtm = (FloatingActionButton) findViewById(R.id.addReview);
    trendingBtm.setOnClickListener(btTrending);
    userBtm.setOnClickListener(btUser);
    locationBtm.setOnClickListener(btlocation);
    settingsBtm.setOnClickListener(btSettings);
    addReviewBtm.setOnClickListener(btAdd);


}
项目:Hands-On-Android-UI-Development    文件:NavigationMenuActivity.java   
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_menu);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
    );

    drawer.addDrawerListener(toggle);
    toggle.syncState();
    drawer.openDrawer(Gravity.START);
}
项目:homeassist-builder    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle("HomeAssist Control Builder");

    mDataTextView = findViewById(R.id.text_data);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showEntityAction();
        }
    });
}
项目:Show_Chat    文件:RegisterActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.chat_activity_register);
    fab = (FloatingActionButton) findViewById(R.id.fab);
    cvAdd = (CardView) findViewById(R.id.cv_add);
    editTextUsername = (EditText) findViewById(R.id.et_username);
    editTextPassword = (EditText) findViewById(R.id.et_password);
    editTextRepeatPassword = (EditText) findViewById(R.id.et_repeatpassword);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ShowEnterAnimation();
    }
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            animateRevealClose();
        }
    });
}
项目:JewelryUI    文件:MainActivity.java   
private void findView() {
    rvRing =(RecyclerViewPager)findViewById(R.id.rv_ring);
    svContainer = (ObservableScrollView) findViewById(R.id.sv_container);
    svDetail = (ScrollView) findViewById(R.id.sv_detail);
    blurringView = (BlurringView) findViewById(R.id.blurring);
    vpModel = (JazzyViewPager) findViewById(R.id.vp_model);
    ivBlur = (ImageView) findViewById(R.id.iv_blur);
    tvName = (TextView) findViewById(R.id.tv_name);

    floatingActionButton = (FloatingActionButton)findViewById(R.id.fab);
    layoutContainer = (RelativeLayout) findViewById(R.id.layout_container);
    layoutFakeRipple = (RelativeLayout) findViewById(R.id.layout_fake_ripple);
    rvCheckOut = (RecyclerView) findViewById(R.id.rv_check_out);
    tvTitle = (TextView) findViewById(R.id.tv_title);
    btnPay = (MorphingButton) findViewById(R.id.btn_pay);
}
项目:RetroMusicPlayer    文件:ScrollAwareFABBehavior.java   
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
                           @NonNull FloatingActionButton child,
                           @NonNull View target,
                           int dxConsumed,
                           int dyConsumed,
                           int dxUnconsumed,
                           int dyUnconsumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);

    //child -> Floating Action Button
    if (dyConsumed > 0) {
        Log.d("Scrolling", "Up");
        CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
        int fab_bottomMargin = layoutParams.bottomMargin;
        child.animate().translationY(child.getHeight() + fab_bottomMargin).setInterpolator(new LinearInterpolator()).start();
    } else if (dyConsumed < 0) {
        Log.d("Scrolling", "down");
        child.animate().translationY(0).setInterpolator(new LinearInterpolator()).start();
    }
}
项目:Channelize    文件:TaskListFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_task_list, container, false);

    mTextEmptyList = (TextView) view.findViewById(R.id.text_empty_list);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_main);
    mFab = (FloatingActionButton) view.findViewById(R.id.fab_add);

    mLayoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(mLayoutManager);
    RecyclerView.ItemDecoration itemDecoration = new
            DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL);
    mRecyclerView.addItemDecoration(itemDecoration);

    setClickListeners();
    setupBroadcastReceiver();

    return view;
}
项目:Android_RuuvitagScannner    文件:EditActivity.java   
@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.activity_edit);
    textfield = (EditText) findViewById(R.id.input_name);
    handler = new DBHandler(this);
    db = handler.getWritableDatabase();

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openAlarmEdit(view);
            save(null);
        }
    });

    if(getIntent().getExtras() != null) {
        index = getIntent().getExtras().getInt("index");
    }
}
项目:natumassas-app    文件:AddCliente.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_cliente);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    editNome = (EditText) findViewById(R.id.editNome);
    editTelefone = (EditText) findViewById(R.id.editTelefone);
    editEndereco = (EditText) findViewById(R.id.editEndereco);
    editEmail = (EditText) findViewById(R.id.editEmail);

    fab = (FloatingActionButton) findViewById(R.id.btnConfirmAddCliente);

    dbConnection = new DBConnection();
    dbConnection.createConnection(this);

}
项目:Android-Development    文件:PoiListFragment.java   
/**
 * Setup {@link PoiListFragment} static views and their click listeners
 */
private void setupView() {
    TextView osmCopyright = (TextView) getActivity().findViewById(R.id.osmCopyright);
    osmCopyright.setText(Html.fromHtml(getString(R.string.osm_copyright)));

    relativeLayout = (RelativeLayout) getActivity().findViewById(R.id.mapViewPoiListContainer);
    floatingActionButton = (FloatingActionButton) getActivity().findViewById(R.id.fabPoiList);
    floatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (!mapPreviewVisible) {
                floatingActionButton.setImageResource(R.drawable.ic_close_white);
                relativeLayout.setVisibility(View.VISIBLE);
                mapPreviewVisible = true;
            } else {
                floatingActionButton.setImageResource(R.drawable.ic_map_white);
                relativeLayout.setVisibility(View.GONE);
                mapPreviewVisible = false;
            }
        }
    });
}
项目:TeamCSSS-Enactus    文件:sampleReport.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_report);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}
项目:Gonnect    文件:SecondActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}
项目:ButterflyButton    文件:ButterflyButton.java   
private void init(Context context, AttributeSet attributeSet) {
    this.model = new ButterflyModel(context);
    View root = inflate(context, R.layout.domlayout, this);
    this.screenMetrics = context.getResources().getDisplayMetrics();
    this.floatingActionButton = (FloatingActionButton) root.findViewById(R.id.fab);
    this.floatingActionButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (model.isOpened()) {
                closeBubble();
            } else {
                openBubble();
            }
        }
    });
    if (attributeSet != null)
        applyStyling(context.obtainStyledAttributes(attributeSet, R.styleable.ButterflyButton));
    setMinimumWidth((int) this.model.getMaxRadius());
    setMinimumHeight((int) this.model.getMaxRadius());
}
项目:TeamCSSS-Enactus    文件:MainActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i=new Intent(getApplicationContext(),sampleReport.class);
            startActivity(i);
        }
    });
}
项目:DebugOverlay-Android    文件:ScrollingActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrolling);

    ToolbarSupport.addTo(this);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}
项目:HDImageView    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();

            mImage.setTranslateLimit(Translation.COUSTOM);
        }
    });

    mImage = (CropHDImageView) findViewById(R.id.image);

    mImage.setImageSource(ImageSourceBuilder.newBuilder()
                .setUri(ASSET_SCHEME+"girl.jpg").build());
}
项目:civify-app    文件:NavigateFragment.java   
private void setCenterButton(View v) {
    mFabLocation = (FloatingActionButton) v.findViewById(R.id.fab_location);
    mLocationListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                Float zoom = null;
                // Disable search
                if (mSarchCenterSnackbar != null) {
                    CivifyMap.getInstance().enable();
                    CivifyMap.getInstance().setAutoCenter(getSharedPreferencesAutoCenter());
                    mSarchCenterSnackbar.dismiss();
                    mSarchCenterSnackbar = null;
                    zoom = mLastZoom;
                }
                CivifyMap.getInstance()
                        .center(CivifyMap.getInstance().getCurrentLocation(), zoom, true);
            } catch (MapNotLoadedException ignore) {
                showMapLoadingWarning(view);
            }
        }
    };
    mFabLocation.setOnClickListener(mLocationListener);
}
项目:FakeWeather    文件:FloatingActionButtonScrollBehavior.java   
@Override
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final
FloatingActionButton child, final View target, final int dxConsumed, final int dyConsumed,
                           final int dxUnconsumed, final int dyUnconsumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed,
            dxUnconsumed, dyUnconsumed);
    if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
        /** design lib 升级到 25.1.0 导致 child.hide() 效果失效,法克哟
         *  http://stackoverflow.com/questions/41761736/android-design-library-25-1-0-causes-floatingactionbutton-behavior-to-stop-worki
         */
        child.hide(new FloatingActionButton.OnVisibilityChangedListener() {
            @Override
            public void onHidden(FloatingActionButton fab) {
                super.onHidden(fab);
                fab.setVisibility(View.INVISIBLE);
            }
        });
    } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
        child.show();
    }
}
项目:Tusky    文件:TimelineFragment.java   
@Override
public void onScrolled(RecyclerView view, int dx, int dy) {
    super.onScrolled(view, dx, dy);

    ActionButtonActivity activity = (ActionButtonActivity) getActivity();
    FloatingActionButton composeButton = activity.getActionButton();

    if (composeButton != null) {
        if (hideFab) {
            if (dy > 0 && composeButton.isShown()) {
                composeButton.hide(); // hides the button if we're scrolling down
            } else if (dy < 0 && !composeButton.isShown()) {
                composeButton.show(); // shows it if we are scrolling up
            }
        } else if (!composeButton.isShown()) {
            composeButton.show();
        }
    }
}
项目:ankihelper    文件:PlansManagerActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_plans_manager);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.add_plan);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (MyApplication.getAnkiDroid().isAnkiDroidRunning()) {
                Intent intent = new Intent(PlansManagerActivity.this, PlanEditorActivity.class);
                startActivity(intent);
            } else {
                DialogUtil.showStartAnkiDialog(PlansManagerActivity.this);
            }
        }
    });

}
项目:Camera-Roll-Android-App    文件:MainActivity.java   
public void fabClicked(View v) {
    if (v instanceof FloatingActionButton) {
        FloatingActionButton fab = (FloatingActionButton) v;
        Drawable drawable = fab.getDrawable();
        if (drawable instanceof Animatable) {
            ((Animatable) drawable).start();
        }
    }
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent i = new Intent();
            i.setAction(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
            if (i.resolveActivity(getPackageManager()) != null) {
                startActivity(i);
            } else {
                Toast.makeText(MainActivity.this, getString(R.string.error), Toast.LENGTH_SHORT).show();
            }
        }
    }, (int) (500 * Util.getAnimatorSpeed(this)));
}
项目:wirtualnaApteczka    文件:AddMedicineActivity.java   
private void initializeViewComponents() {
    nameEdit = (EditText) findViewById(R.id.medicine_name);
    nameEdit.setSelected(false);
    amountEdit = (EditText) findViewById(R.id.medicine_amount);
    amountEdit.setSelected(false);
    notesEdit = (EditText) findViewById(R.id.notes_text);
    notesEdit.setSelected(false);

    quantitySuffixLabel = (TextView) findViewById(R.id.medicine_quantity_suffix_label);
    dueDateCalendar = (TextView) findViewById(R.id.medicine_due_date_calendar);
    saveMedicineBtn = (FloatingActionButton) findViewById(R.id.save_new_medicine_btn);
    medicineTypeSpinner = (Spinner) findViewById(R.id.medicine_type_spinner);
    shareMedicineWithFriends = (CheckBox) findViewById(R.id.share_medicine_checkbox);

    addMedicinePhotoBtn = (ImageButton) findViewById(R.id.add_medicine_photo);
    voiceInputMedicineNameBtn = (ImageButton) findViewById(R.id.voice_input_medicine_name_btn);
    voiceInputMedicineNotesBtn = (ImageButton) findViewById(R.id.voice_input_medicine_notes_btn);
}
项目:Kutuk    文件:NamedListActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.named_list);
    realm = Realm.getDefaultInstance();
    RecyclerView namedView = (RecyclerView) findViewById(R.id.named_list_view);
    namedView.setLayoutManager(new LinearLayoutManager(this));
    namedView.setAdapter(getViewAdapter());

    FloatingActionButton addButton = (FloatingActionButton) findViewById(R.id.add_button);
    addButton.setImageDrawable(MaterialDrawableBuilder.with(this)
            .setIcon(MaterialDrawableBuilder.IconValue.PLUS)
            .setColorResource(R.color.text_light)
            .build()
    );
}
项目:Android-Photo-Cell-POC    文件:FlashActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flash);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Starting Flash Light", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();

            runFlashSpeedTest();
        }
    });
}
项目:gigreminder    文件:ArtistsFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_artists, container, false);
    ButterKnife.bind(this, rootView);

    adapter = new ListAdapter(getContext(), uiModel);
    adapter.setOnItemClickListener(createOnArtistClickListener());

    artistsView.setHasFixedSize(true);
    artistsView.setAdapter(adapter);
    artistsView.setLayoutManager(new LinearLayoutManager(getContext()));
    artistsView.addItemDecoration(new DividerItemDecoration(getContext(),
            LinearLayoutManager.VERTICAL));

    listHelper = new ListViewHelper(artistsView, emptyListView, loadingProgressView);

    FloatingActionButton addArtistButton = (FloatingActionButton) getActivity().findViewById(
            R.id.fab_add_artist);
    addArtistButton.setOnClickListener(v -> {
        presenter.sendUiEvent(OpenNewArtistEvent.INSTANCE);
    });

    return rootView;
}
项目:boohee_v5.6    文件:StepMainActivity$$ViewInjector.java   
public void inject(Finder finder, final T target, Object source) {
    target.mPullRefreshListView = (PullToRefreshListView) finder.castView((View) finder
            .findRequiredView(source, R.id.listview, "field 'mPullRefreshListView'"), R.id
            .listview, "field 'mPullRefreshListView'");
    View view = (View) finder.findRequiredView(source, R.id.fab_button, "field 'fabButton' " +
            "and method 'onClick'");
    target.fabButton = (FloatingActionButton) finder.castView(view, R.id.fab_button, "field " +
            "'fabButton'");
    view.setOnClickListener(new DebouncingOnClickListener() {
        public void doClick(View p0) {
            target.onClick(p0);
        }
    });
    target.tvIndicator = (View) finder.findRequiredView(source, R.id.tv_indicator, "field " +
            "'tvIndicator'");
}
项目:Microsphere    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            new DetectionTask().execute(path);
        }
    });
    add_log(stringFromJNI());
    TextView tv = (TextView) findViewById(R.id.sample_text);
    tv.setMovementMethod(new ScrollingMovementMethod());
    get_permission();
    init_system();
}
项目:TeamCSSS-Enactus    文件:homePage.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home_page);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
项目:CoordinatorLayoutExample-master    文件:MyBehaviorActivity.java   
private void initView(){
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    coordinatorLayout=(CoordinatorLayout)findViewById(R.id.behavior_demo_coordinatorLayout);

    recyclerview=(RecyclerView)findViewById(R.id.behavior_demo_recycler);
    mLayoutManager=new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    recyclerview.setLayoutManager(mLayoutManager);

    swipeRefreshLayout=(SwipeRefreshLayout) findViewById(R.id.behavior_demo_swipe_refresh) ;
    swipeRefreshLayout.setProgressViewOffset(false, 0,  (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()));//调整下拉控件位置

    fab=(FloatingActionButton) findViewById(R.id.fab);
}
项目:stynico    文件:WelcomeActivity.java   
private void initInstances() {
    fabBtn = (FloatingActionButton) findViewById(R.id.fab);
    fabBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText editText = (EditText)findViewById(R.id.tv_no);
                String strurl = String.valueOf(editText.getText());
                ClipboardManager manager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                manager.setText(""+"\n");

            }
        });
}
项目:CommonLibrary    文件:Main2Activity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMain2Binding binding = DataBindingUtil.setContentView(this,R.layout.activity_main2);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
//                        .setAction("Action", null).show();
            }
        });




        List<Test> data = new ArrayList<>();
        Test test;
        for (int i = 0; i < 100; i++) {
            test = new Test();
            test.name = i +"";
            test.time = System.currentTimeMillis() + "->"+i;
            data.add(test);
        }
        adapter.setData(data);


        binding.content.rc.setLayoutManager(new LinearLayoutManager(this));
        binding.content.rc.setAdapter(adapter);

    }
项目:SecScanQR    文件:GenerateActivity.java   
/**
 * Standard Android on create method that gets called when the activity
 * initialized.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_generate);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    text = (EditText) findViewById(R.id.txtQR);
    image = (ImageView) findViewById(R.id.image);

    //Setup the Spinner Menu for the different formats
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    spinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.formats_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);


    //If the device were rotated then restore information
    if(savedInstanceState != null){
        text2Qr = (String) savedInstanceState.get(STATE_TEXT);
        text.setText(text2Qr);
    }

    // Get intent, action and MINE type and check if the intent was started by a share to modul from an other app
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Intent.ACTION_SEND.equals(action) && type != null){
        if("text/plain".equals(type)){
            handleSendText(intent); //call method to handle sended text
        }
    }

    //OnClickListener for the "+" Button and functionality
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            text2Qr = text.getText().toString().trim();
            if(text2Qr.equals("")){
                Toast.makeText(getApplicationContext(), getResources().getText(R.string.error_text_first), Toast.LENGTH_SHORT).show();
            } else {
                multiFormatWriter = new MultiFormatWriter();
                try{
                    BitMatrix bitMatrix = multiFormatWriter.encode(text2Qr, format, 500,500);
                    BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
                    bitmap = barcodeEncoder.createBitmap(bitMatrix);
                    image.setImageBitmap(bitmap);
                } catch (Exception e){
                    Toast.makeText(activity.getApplicationContext(), getResources().getText(R.string.error_generate), Toast.LENGTH_LONG).show();
                }
            }

        }
    });

}
项目:fab-submenu    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    fabSettings = (FloatingActionButton) this.findViewById(R.id.fabSetting);

    layoutFabSave = (LinearLayout) this.findViewById(R.id.layoutFabSave);
    layoutFabEdit = (LinearLayout) this.findViewById(R.id.layoutFabEdit);
    layoutFabPhoto = (LinearLayout) this.findViewById(R.id.layoutFabPhoto);
    //layoutFabSettings = (LinearLayout) this.findViewById(R.id.layoutFabSettings);

    //When main Fab (Settings) is clicked, it expands if not expanded already.
    //Collapses if main FAB was open already.
    //This gives FAB (Settings) open/close behavior
    fabSettings.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (fabExpanded == true){
                closeSubMenusFab();
            } else {
                openSubMenusFab();
            }
        }
    });

    //Only main FAB is visible in the beginning
    closeSubMenusFab();
}
项目:Oremus    文件:ScrollingActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrolling);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i = new Intent(ScrollingActivity.this,MainActivity.class);
            startActivity(i);
        }
    });


    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (!prefs.getBoolean("firstTime", false)) {

        Intent alarmIntent = new Intent(this, AlarmReciever.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0);

        AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.set(Calendar.HOUR_OF_DAY, 6);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 1);

        manager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
                AlarmManager.INTERVAL_DAY, pendingIntent);

        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean("firstTime", true);
        editor.apply();
    }

}
项目:Eye    文件:HomeActivity.java   
/**
 * Starts the activity and gets the references to the
 * inflated UI components; also calculates the screen
 * dimensions, sets up the initial state of the app
 * and the camera.
 *
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = getApplicationContext();
    setContentView(R.layout.activity_home);

    try {
        getSupportActionBar().hide();
    } catch (NullPointerException ignored) {
        Log.d(TAG, "Null pointer exception while hiding the action bar.");
    } catch (Exception e) {
        Log.d(TAG, "Eexception while hiding the action bar : " + e.getMessage());
    }


    introHintView = findViewById(R.id.introHint);
    mFaceOverlays = (RelativeLayout) findViewById(R.id.facesOverlay);
    mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
    mDetectedTextView = (TextView) findViewById(R.id.detectedTextView);
    mTrackingTextView = (TextView) findViewById(R.id.trackingTextView);
    mSelectorSwitch = (SelectorSwitch) findViewById(R.id.LODSwitch);
    previewFAB = (FloatingActionButton) findViewById(R.id.startPreviewBtn);
    activity = this;

    mSurfaceView.post(new Runnable() {
        @Override
        public void run() {
            screenMaxX = mSurfaceView.getWidth();
            screenMaxY = mSurfaceView.getHeight();
            setupInitialState();
            setupOutputSurfaces();
            status_OK = setupCamera();
        }
    });
}
项目:apps_small    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // The floating action button.
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Please enter your username and password.", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    // They should log in.
    logInBool = true;

    // Define our views.
    registerText = (TextView)findViewById(R.id.registerText);
    logInButton = (Button)findViewById(R.id.loginButton);
    passText = (EditText) findViewById(R.id.passwordEditText);
    nameText = (EditText)findViewById(R.id.nameEditText);
    linLogLay = (LinearLayout)findViewById(R.id.linLogLay);
    camLogo = (ImageView)findViewById(R.id.camLogo);

    // Define our listeners.
    camLogo.setOnClickListener(this);
    linLogLay.setOnClickListener(this);
    passText.setOnKeyListener(this);


    // Set the default values
    logInButton.setText("Log in!");
    registerText.setText("Register");

}
项目:labtablet    文件:ScrollAwareFabBehavior.java   
@Override
public void onNestedScroll(final CoordinatorLayout coordinatorLayout,
                           final FloatingActionButton child,
                           final View target, final int dxConsumed, final int dyConsumed,
                           final int dxUnconsumed, final int dyUnconsumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed,
            dxUnconsumed, dyUnconsumed);
    if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
        // User scrolled down and the FAB is currently visible -> hide the FAB
        child.hide();
    } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
        // User scrolled up and the FAB is currently not visible -> show the FAB
        child.show();
    }
}
项目:Gallery-example    文件:MediaBrowser.java   
@Override
public void onCompletion(EasyVideoPlayer player) {
    // TODO handle if needed

    fabPlay.show(new FloatingActionButton.OnVisibilityChangedListener() {
        @Override
        public void onShown(FloatingActionButton fab) {
            photoView.setVisibility(View.VISIBLE);
            videoView.setVisibility(View.GONE);

        }
    });
}