FloatingActionButton icon indicating copy to clipboard operation
FloatingActionButton copied to clipboard

Label is getting passed in OnClick() when i click fab buttons label instead of FAB button instance

Open akshay-shah opened this issue 8 years ago • 2 comments

i add fab buttons like this

floatingMenuSort.setVisibility(View.VISIBLE); for (int i = 0; i < sort_options_title.size(); i++) { FloatingActionButton fab = new FloatingActionButton(CategoryListActivity.this); fab.setButtonSize(FloatingActionButton.SIZE_MINI); fab.setLabelText(sort_options_title.get(i)); fab.setColorNormal(Color.parseColor("#00aeef")); fab.setColorPressed(Color.parseColor("#00aeef")); fab.setColorRipple(Color.parseColor("#00aeef")); fab.setTag(sort_option_value.get(i)); fab.setOnClickListener(CategoryListActivity.this); switch (sort_option_value.get(i)) { case "pops": fab.setImageResource(R.drawable.popular); break; case "priceltoh": fab.setImageResource(R.drawable.sortasce); break; case "pricehtol": fab.setImageResource(R.drawable.sortdesc); break; case "discount": fab.setImageResource(R.drawable.percent); break; } floatingMenuSort.addMenuButton(fab); }

so in onclick i recieve an instance of label when label is clicked whereas i should recieve instance of fab button

akshay-shah avatar Sep 12 '16 13:09 akshay-shah

i did this to solve that problem (which is annoying!): after adding the fabButton with addMenuButton, i've set the tags, on both button and label, like so: listFab.addMenuButton(b); b.setTag(o.getString("id")); View label = (View) b.getTag(R.id.fab_label); if(label != null) label.setTag(o.getString("id")); hope that helps, cheers

givolaj avatar May 02 '17 21:05 givolaj

You can also work around this problem by calling addMenuButton(fab) BEFORE calling setOnClickListener

kris-sum avatar May 03 '19 13:05 kris-sum