本文整理汇总了Java中android.support.design.widget.FloatingActionButton.setImageResource方法的典型用法代码示例。如果您正苦于以下问题:Java FloatingActionButton.setImageResource方法的具体用法?Java FloatingActionButton.setImageResource怎么用?Java FloatingActionButton.setImageResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.FloatingActionButton
的用法示例。
在下文中一共展示了FloatingActionButton.setImageResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOptionsItemSelected
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_reset) {
DatabaseService.getInstance().resetItems();
mAdapter.updateDataSet(DatabaseService.getInstance().getDatabaseList(), true);
} else if (id == R.id.action_delete) {
DatabaseService.getInstance().removeAll();
mAdapter.updateDataSet(null, true);
// This is necessary if we call updateDataSet() and not removeItems
DatabaseService.getInstance().resetHeaders();
// Change fab action (ADD NEW ITEM UNTIL 15)
FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
fab.setImageResource(R.drawable.fab_add);
}
return super.onOptionsItemSelected(item);
}
示例2: addItem
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private int addItem(StaggeredItemStatus status, StaggeredHeaderItem headerItem) {
StaggeredItem staggeredItem = DatabaseService.newStaggeredItem(
DatabaseService.getInstance().getMaxStaggeredId(), headerItem);
staggeredItem.setStatus(status);//!!!
// The section object is known
mAdapter.addItemToSection(staggeredItem, staggeredItem.getHeader(),
new DatabaseService.ItemComparatorByGroup());
// Add Item to the Database as well for next refresh
DatabaseService.getInstance().addItem(staggeredItem, new DatabaseService.ItemComparatorById());
// Change fab action (MOVE ITEM)
if (mAdapter.getItemCountOfTypes(R.layout.recycler_staggered_item) >= 15) {
FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
fab.setImageResource(R.drawable.ic_sort_white_24dp);
}
// Retrieve the final position due to a possible hidden header became now visible!
int scrollTo = mAdapter.getGlobalPositionOf(staggeredItem);
Log.d(TAG, "Creating New Item " + staggeredItem + " at position " + scrollTo);
return scrollTo;
}
示例3: initButtons
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
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);
}
}
示例4: defaultAction
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
public boolean defaultAction(View view) {
TextView gameStatus = (TextView) findViewById(R.id.gameStatusView);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
EditText editText = (EditText) findViewById(R.id.editText);
TextView resultView = (TextView) findViewById(R.id.resultView);
if (currentWord != null) {
currentWord = dictionary.pickGoodStarterWord();
anagrams = dictionary.getAnagrams(currentWord);
gameStatus.setText(Html.fromHtml(String.format(START_MESSAGE, currentWord.toUpperCase(), currentWord)));
fab.setImageResource(android.R.drawable.ic_menu_help);
fab.hide();
resultView.setText("");
editText.setText("");
editText.setEnabled(true);
editText.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
} else {
editText.setText(currentWord);
editText.setEnabled(false);
fab.setImageResource(android.R.drawable.ic_media_play);
currentWord = null;
resultView.append(TextUtils.join("\n", anagrams));
gameStatus.append(" Hit 'Play' to start again");
}
return true;
}
示例5: onActivityCreated
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
FloatingActionButton fab = getActivity().findViewById(R.id.fab_edit_task_done);
fab.setImageResource(R.drawable.ic_done);
fab.setOnClickListener(__ -> mPresenter.saveTask(mTitle.getText().toString(),
mDescription.getText().toString()));
}
示例6: initializeFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
/**
* Display FAB button and restore default icon
*/
protected void initializeFab() {
mFab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
mFab.setImageResource(R.drawable.fab_add);
ViewCompat.animate(mFab)
.scaleX(1f).scaleY(1f)
.alpha(1f).setDuration(100)
.setStartDelay(300L)
.start();
}
示例7: updateFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void updateFab() {
FloatingActionButton fab = findViewById(R.id.fab_delete);
if (isDownloading) {
fab.setImageResource(R.drawable.ic_cancel);
stateView.setText("DOWNLOADING");
} else {
fab.setImageResource(R.drawable.ic_delete);
stateView.setText("DOWNLOADED");
}
}
示例8: bind
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
/**
* sets text of article
*
* @param appcontent Appcontent object that contains information of article
*/
private void bind(final Appcontent appcontent) {
TextView titleTV = (TextView) findViewById(R.id.tv_appcontent_article_title);
TextView writerTV = (TextView) findViewById(R.id.tv_appcontent_article_writer);
TextView dateTV = (TextView) findViewById(R.id.tv_appcontent_article_date);
WebView contentWV = (WebView) findViewById(R.id.wv_appcontent_article_content);
titleTV.setText(appcontent.getTitle());
writerTV.setText(appcontent.getWriter());
dateTV.setText(appcontent.getDate());
contentWV.loadData(appcontent.getContent(), "text/html; charset=UTF-8", null);
mFAB = (FloatingActionButton) findViewById(R.id.fab_appcontent_article);
final List<Attachment> attachmentList = appcontent.getAttachmentList();
if (attachmentList != null && attachmentList.size() != 0) {
mFAB.setImageResource(R.drawable.ic_file_download_white_24dp);
mFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DownloadAttachmentDialogFragment
.newInstance(AppcontentArticleActivity.this, attachmentList)
.show(getSupportFragmentManager(), null);
}
});
mFAB.setVisibility(View.VISIBLE);
}
}
示例9: onCreateView
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.tasks_frag, container, false);
// Set up tasks view
ListView listView = root.findViewById(R.id.tasks_list);
listView.setAdapter(mListAdapter);
mFilteringLabelView = root.findViewById(R.id.filteringLabel);
mTasksView = root.findViewById(R.id.tasksLL);
// Set up no tasks view
mNoTasksView = root.findViewById(R.id.noTasks);
mNoTaskIcon = root.findViewById(R.id.noTasksIcon);
mNoTaskMainView = root.findViewById(R.id.noTasksMain);
mNoTaskAddView = root.findViewById(R.id.noTasksAdd);
mNoTaskAddView.setOnClickListener(__ -> showAddTask());
// Set up floating action button
FloatingActionButton fab = getActivity().findViewById(R.id.fab_add_task);
fab.setImageResource(R.drawable.ic_add);
fab.setOnClickListener(__ -> mPresenter.addNewTask());
// Set up progress indicator
final ScrollChildSwipeRefreshLayout swipeRefreshLayout =
root.findViewById(R.id.refresh_layout);
swipeRefreshLayout.setColorSchemeColors(
ContextCompat.getColor(getActivity(), R.color.colorPrimary),
ContextCompat.getColor(getActivity(), R.color.colorAccent),
ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark)
);
// Set the scrolling view in the custom SwipeRefreshLayout.
swipeRefreshLayout.setScrollUpChild(listView);
swipeRefreshLayout.setOnRefreshListener(() -> mPresenter.loadTasks(false));
setHasOptionsMenu(true);
return root;
}
示例10: initFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void initFab(FloatingActionButton fab) {
fab.setVisibility(View.GONE);
fab.setImageResource(R.drawable.ic_drawer);
fab.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorPrimary)));
}
示例11: initFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void initFab(FloatingActionButton fab) {
fab.setSize(FloatingActionButton.SIZE_MINI);
fab.setImageResource(R.drawable.ic_up);
fab.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorPrimary)));
}
示例12: initFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void initFab(FloatingActionButton fab) {
fab.setVisibility(View.GONE);
fab.setImageResource(R.drawable.ic_share);
fab.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorPrimary)));
}
示例13: initFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
protected void initFab(FloatingActionButton fab) {
fab.setSize(FloatingActionButton.SIZE_MINI);
fab.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorPrimary)));
fab.setImageResource(R.drawable.ic_up);
}
示例14: initView
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
public void initView() {
// toolbar = (Toolbar) findViewById(R.id.tb_toolbar);
// collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.ctl_layout);
// floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_avatar);
floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_activity_user_detail_button);
floatingActionButton.setImageResource(R.drawable.ic_mode_edit_blue_grey_900_24dp);
// display = (RecyclerView) findViewById(R.id.rcl_content);
display = (RecyclerView) findViewById(R.id.rcv_activity_user_detail_display);
refresh = (SwipeRefreshLayout) findViewById(R.id.refresh_activity_user_detail_refresh);
// bgCover = (ImageView) findViewById(R.id.iv_background_cover);
// appBarLayout = (AppBarLayout) findViewById(R.id.al_appbar_layout);
bottomInput = (LinearLayout) findViewById(R.id.ll_user_detail_bottom);
input = (EditText) findViewById(R.id.et_user_detail_input);
send = (ImageView) findViewById(R.id.iv_user_detail_send);
rootContainer = (RelativeLayout) findViewById(R.id.rl_activity_user_detail_container);
rootContainer.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect rect = new Rect();
rootContainer.getWindowVisibleDisplayFrame(rect);
screenHeight = rootContainer.getRootView().getHeight();
int keyBoardHeight = screenHeight - rect.bottom;
int status = getStatusHeight();
if (keyBoardHeight != mKeyBoardHeight) {
if (keyBoardHeight > mKeyBoardHeight) {
bottomInput.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) bottomInput.getLayoutParams();
int realHeight = screenHeight - status - bottomInput.getHeight() - keyBoardHeight;
layoutParams.setMargins(0, realHeight, 0, 0);
bottomInput.setLayoutParams(layoutParams);
mKeyBoardHeight = keyBoardHeight;
floatingActionButton.setVisibility(View.GONE);
mLinearLayoutManager.scrollToPositionWithOffset(currentPosition, getListOffset());
} else {
floatingActionButton.setVisibility(View.VISIBLE);
mKeyBoardHeight = keyBoardHeight;
bottomInput.setVisibility(View.GONE);
}
}
}
});
// appBarLayout.addOnOffsetChangedListener(this);
send.setOnClickListener(this);
refresh.setOnRefreshListener(this);
floatingActionButton.setOnClickListener(this);
rootContainer.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (mCommentPopupWindow != null && mCommentPopupWindow.isShowing()) {
mCommentPopupWindow.dismiss();
}
// 这里进行点击关闭编辑框
if (bottomInput.getVisibility() == View.VISIBLE) {
LogUtil.e("触摸界面点击关闭输入法");
dealBottomView(false);
return true;
}
return false;
}
});
}
示例15: buttonInit
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
/**
* それぞれのボタンの初期設定を行う
*/
private void buttonInit(){
FloatingActionButton fabAuto = (FloatingActionButton) fragment.findViewById(R.id.autoScroll);
switch(autoScrollState){
case 0:
fabAuto.setImageResource(R.drawable.auto_scroll);
checkFab(fabAuto,false);
break;
case 1:
checkFab(fabAuto,true);
break;
case 2:
fabAuto.setImageResource(R.drawable.pause);
checkFab(fabAuto,true);
break;
}
checkFab((FloatingActionButton) fragment.findViewById(R.id.fabDown),downFrag);
checkFab((FloatingActionButton) fragment.findViewById(R.id.fabUp),upFrag);
checkFab((FloatingActionButton) fragment.findViewById(R.id.fabStop),stopFrag);
FloatingActionButton fabNumber = (FloatingActionButton) fragment.findViewById(R.id.fabNumber);
TextView textName=(TextView) fragment.findViewById(R.id.textname);
TextView textNumber=(TextView) fragment.findViewById(R.id.textNumber);
switch(numberState){
case 0:
numberFrag=true;
nameFrag=true;
textName.setVisibility(View.VISIBLE);
textNumber.setVisibility(View.VISIBLE);
checkFab(fabNumber,true);
break;
case 1:
numberFrag=false;
nameFrag=false;
textName.setVisibility(View.VISIBLE);
textNumber.setVisibility(View.VISIBLE);
checkFab(fabNumber,false);
break;
case 2:
numberFrag=true;
nameFrag=false;
textName.setVisibility(View.INVISIBLE);
textNumber.setVisibility(View.VISIBLE);
checkFab(fabNumber,true);
break;
case 3:
numberFrag=false;
nameFrag=true;
textName.setVisibility(View.VISIBLE);
textNumber.setVisibility(View.INVISIBLE);
checkFab(fabNumber,true);
break;
}
}