每当我点击我的浮动动作按钮时,会出现另外两个浮动动作按钮,一个打开相机另一个上传图片,问题是当我选择子动作按钮并转到下一个活动时,一切工作正常但当我返回浮动操作按钮的主页面时,两个子按钮仍在主浮动按钮之外
我必须重新打开应用程序来修复它,
这是我的代码
private void setupFloatingActionMenu(Context context) {
ImageView imgv = new ImageView(context); // Create an icon
imgv.setImageResource(R.drawable.ic_launcher);
FloatingActionButton actionButton = new FloatingActionButton.Builder((Activity) context)
.setContentView(imgv)
.build();
ImageView capture = new ImageView(context);
capture.setImageResource(R.drawable.ic_launcher);
ImageView upload = new ImageView(context);
upload.setImageResource(R.drawable.ic_launcher);
SubActionButton.Builder itemBuilder = new SubActionButton.Builder((Activity) context);
SubActionButton buttonSortCap = itemBuilder.setContentView(capture).build();
SubActionButton buttonSortUpd = itemBuilder.setContentView(upload).build();
FloatingActionMenu actionMenu = new FloatingActionMenu.Builder((Activity) context)
.addSubActionView(buttonSortCap)
.addSubActionView(buttonSortUpd)
.setRadius(150)
.enableAnimations()
.attachTo(imgv)
.build();
buttonSortCap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
captureImage();
}
});
buttonSortUpd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, ""), PICK_IMAGE);
}
});
}