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


Java FloatingActionButton.setOnClickListener方法代码示例

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


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

示例1: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_debug);
  ButterKnife.bind(this);

  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();
    }
  });

  initNavigationDrawer();

  NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);

  // Local web server
  setupWebServer();
}
 
开发者ID:zugaldia,项目名称:android-robocar,代码行数:27,代码来源:DebugActivity.java

示例2: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@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();
        }
    });

    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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:MainActivity.java

示例3: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_homepage);
    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);


}
 
开发者ID:addy-org,项目名称:Addy-Android,代码行数:28,代码来源:Homepage.java

示例4: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(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();
        }
    });

    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);


    // Initialize wifi manager and wifi receiver for onCreate.
    wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    receiver = new WifiReceiver(wifiManager, this);

    this.requestPermissions();
}
 
开发者ID:ProjectIndoor,项目名称:projectindoorapp,代码行数:40,代码来源:MapActivity.java

示例5: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@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();
}
 
开发者ID:ptyagicodecamp,项目名称:fab-submenu,代码行数:32,代码来源:MainActivity.java

示例6: baseInit

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
/**
 * 视图上的初始化
 */
private void baseInit() {

    visibility = findViewById(R.id.no_event_layout);    // showNoEvent 用

    // add Button的设置
    add = (FloatingActionButton) findViewById(R.id.add_event);
    add.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            EditMenuFragment dialog = new EditMenuFragment();
            Bundle bundle = new Bundle();
            bundle.putSerializable("adapter", MyAdapter);
            //获取当前事件类别并传入bundle
            int category = (int)mDrawer.getCurrentSelection();
            bundle.putInt("category", category);
            dialog.setArguments(bundle);
            dialog.show(getSupportFragmentManager(), "edit bar");
            view.setVisibility(View.GONE); // 隐藏加号按钮
        }
    });

    if (!haveInit) {
        initEvents();           // 获取数据库 或 创建数据库

        showStartupAnimate();   // 显示启动动画

        eventList = DataSupport.findAll(TodoEvent.class); // 获取 待办事项数据库
        showNoEvent();
    }

    sendNotification(eventList);
    initThemeColor();
    initDrawerLayout();
}
 
开发者ID:wendyltan,项目名称:EasyTodo,代码行数:38,代码来源:MainActivity.java

示例7: initInstances

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
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");
				
			}
		});
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:14,代码来源:WelcomeActivity.java

示例8: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    url = getIntent().getStringExtra(URL_KEY);
    detailContentParsable = new DetailContentParsable(url);

    setContentView(R.layout.activity_view_detail);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    setTitle(getIntent().getStringExtra(TITLE_KEY));

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AppUtil.openWebPageAndShowSnackbarIfFail(ViewDetailActivity.this, url, view);
        }
    });

    toolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    AppUtil.setupSwipeRefreshLayoutColors(swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshAsync();
        }
    });
    detailWebView = (WebView) findViewById(R.id.detail_web_view);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    refreshAsync();
}
 
开发者ID:ShreckYe,项目名称:SCUYouth,代码行数:36,代码来源:ViewDetailActivity.java

示例9: showHelpPopup

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void showHelpPopup(final Activity context) {
    // Inflate the popup_layout.xml
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.help_popup_layout);
    dialog.show();
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.copyFrom(dialog.getWindow().getAttributes());
    dialog.getWindow().setAttributes(lp);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.getWindow().setDimAmount(0);
    // Creating the PopupWindow

    // Clear the default translucent background

    // Displaying the popup at the specified location, + offsets.

    // Getting a reference to Close button, and close the popup when clicked.
    FloatingActionButton close = (FloatingActionButton) dialog.findViewById(R.id.close_help_popup_button);
    close.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.cancel();
        }
    });
}
 
开发者ID:Lekky71,项目名称:WhatsAppStatusSaver,代码行数:29,代码来源:MainActivity.java

示例10: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advanced_usage);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);

    data = Arrays.asList(
            new AdvancedData("Data 1", "detail 1", ViewType.First),
            new AdvancedData("Data 2", "detail 2", ViewType.Second),
            new AdvancedData("Data 3", "detail 3", ViewType.Second),
            new AdvancedData("Data 4", "detail 4", ViewType.Second),
            new AdvancedData("Data 5", "detail 5", ViewType.Third),
            new AdvancedData("Data 6", "detail 6", ViewType.Third)
    );
    source.setData(data);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
            int round = (int) Math.round(Math.random() * (data.size() - 1));
            AdvancedData d = data.get(round);
            d.viewType = ViewType.Mutated;
            source.setData(data);
            Toast.makeText(AdvancedUsageActivity.this, "Mutation at " + round, Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:Team-SOFTsk,项目名称:ObservableAdapter,代码行数:30,代码来源:AdvancedUsageActivity.java

示例11: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@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();

            askForPermission(new String[]{Manifest.permission.SEND_SMS, Manifest.permission.WRITE_EXTERNAL_STORAGE , Manifest.permission.READ_EXTERNAL_STORAGE ,Manifest.permission.USE_SIP , Manifest.permission.GET_ACCOUNTS} ,false, new PermissionCallBack() {

                @Override
                public void onPermissionsGranted() {

                    Toast.makeText(MainActivity.this, "onPermissionsGranted", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onPermissionsDenied(String[] permissions) {
                    Toast.makeText(MainActivity.this, "onPermissionsDenied ", Toast.LENGTH_SHORT).show();
                }
            });

        }
    });
}
 
开发者ID:mahdit83,项目名称:advancedPermissionHandler,代码行数:32,代码来源:MainActivity.java

示例12: initViews

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
/**
 * Bind views XML with JavaAPI
 */
private void initViews(){
    mProgressBar = (ProgressBar)findViewById(R.id.pb);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(this);
    recyclerView = (RecyclerView)findViewById(R.id.rv_list_feed);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
 
开发者ID:AleBarreto,项目名称:FeedFire,代码行数:12,代码来源:MainActivity.java

示例13: onCreateView

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_user_info, container, false);
    arguments = getArguments();
    email = arguments.getString(EMAIL_BUNDLE_KEY);
    phone = arguments.getString(PHONE_BUNDLE_KEY);
    website = arguments.getString(WEBSITE_BUNDLE_KEY);
    fullName = arguments.getString(FULL_NAME_BUNDLE_KEY);
    presenter.setUserId(arguments.getLong(ID_BUNDLE_KEY));

    Toolbar toolbar = (Toolbar) view.findViewById(R.id.user_toolbar);
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(),
            null, android.support.v7.appcompat.R.styleable.ActionBar, android.support.v7.appcompat.R.attr.actionBarStyle, 0);
    toolbar.setNavigationIcon(a.getDrawable(android.support.v7.appcompat.R.styleable.ActionBar_homeAsUpIndicator));
    toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());

    toolbarLayout = (CollapsingToolbarLayout) view.findViewById(R.id.user_collapsing_toolbar_layout);
    emailTextView = (TextView) view.findViewById(R.id.user_info_email_value);
    phoneTextView = (TextView) view.findViewById(R.id.user_info_phone_value);
    websiteTextView = (TextView) view.findViewById(R.id.user_info_website_value);
    userInfoFab = (FloatingActionButton) view.findViewById(R.id.user_info_fab);
    toolbarLayout.setTitleEnabled(true);
    toolbarLayout.setTitle(fullName);

    view.findViewById(R.id.user_info_email_layout).setOnClickListener(this);
    view.findViewById(R.id.user_info_phone_layout).setOnClickListener(this);
    view.findViewById(R.id.user_info_website_layout).setOnClickListener(this);
    userInfoFab.setOnClickListener(this);

    if (presenter.isCurrentUser()) {
        userInfoFab.setVisibility(View.GONE);
    }

    packageManager = getActivity().getPackageManager();

    return view;
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:39,代码来源:UserInfoFragment.java

示例14: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_friends);

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

    fab.setOnClickListener(this);

    appToken = getIntent().getStringExtra("appToken");

    this.StoreFriends(getIntent().getStringExtra("friends"));

    lat=getIntent().getExtras().getDouble("lat");
    log=getIntent().getExtras().getDouble("log");

    adapter = new FriendsAdapter(this, R.layout.list_item, friends);

    listview = (ListView) findViewById(R.id.listview);
    listview.setAdapter(adapter);

    final ImageButton movie = (ImageButton) this.findViewById(R.id.movie);
    final ImageButton cafe = (ImageButton) this.findViewById(R.id.cafe);
    final ImageButton restaurant = (ImageButton) this.findViewById(R.id.restaurant);
    final ImageButton subway = (ImageButton) this.findViewById(R.id.subway);
    final ImageButton shopping = (ImageButton) this.findViewById(R.id.shopping);

    movieclick=new ImageButtonOnClickListener(movie, R.drawable.movie_c, R.drawable.movie);
    cafeclick=new ImageButtonOnClickListener(cafe, R.drawable.cafe_c, R.drawable.cafe);
    restaurantclick=new ImageButtonOnClickListener(restaurant,R.drawable.restaurant_c, R.drawable.restaurant);
    subwayclick=new ImageButtonOnClickListener (subway,R.drawable.subway_c, R.drawable.subway);
    shoppingclick=new ImageButtonOnClickListener (shopping,R.drawable.shopping_c, R.drawable.shopping);

    movie.setOnClickListener(movieclick);
    cafe.setOnClickListener(cafeclick);
    restaurant.setOnClickListener(restaurantclick);
    subway.setOnClickListener(subwayclick);
    shopping.setOnClickListener(shoppingclick);
}
 
开发者ID:ChristopherJdL,项目名称:wheretomeet-android,代码行数:41,代码来源:FriendsActivity.java

示例15: onCreate

import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_capture_claim);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton attach = (FloatingActionButton) findViewById(R.id.attach);
    attach.setOnClickListener(this);

    selectedDate = (DatePickerLayout) findViewById(R.id.date);

    description = (EditText) findViewById(R.id.description);
    amount = (EditText) findViewById(R.id.amount);
    selectedDate = (DatePickerLayout) findViewById(R.id.date);

    final FragmentManager fragmentManager = getSupportFragmentManager();
    attachments = (AttachmentPagerFragment) fragmentManager.findFragmentById(R.id.attachments);
    categories = (CategoryPickerFragment) fragmentManager.findFragmentById(R.id.categories);

    if (savedInstanceState != null) {
        claimItem = savedInstanceState.getParcelable(KEY_CLAIM_ITEM);
    } else if (getIntent().hasExtra(EXTRA_CLAIM_ITEM)) {
        claimItem = getIntent().getParcelableExtra(EXTRA_CLAIM_ITEM);
    }

    if (claimItem == null) {
        claimItem = new ClaimItem();
    } else {
        description.setText(claimItem.getDescription());
        amount.setText(String.format("%f", claimItem.getAmount()));
        selectedDate.setDate(claimItem.getTimestamp());
    }

    attachments.setClaimItem(claimItem);
}
 
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:37,代码来源:CaptureClaimActivity.java


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