本文整理匯總了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();
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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");
}
});
}
示例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();
}
示例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();
}
});
}
示例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();
}
});
}
示例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();
}
});
}
});
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}