當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。