フローティング アクション ボタンをクリックするたびに、別の 2 つのフローティング アクション ボタンが表示されます。1 つはカメラを開き、もう 1 つは写真をアップロードするためのものです。問題は、サブ アクション ボタンを選択して次のアクティビティに移動すると、すべて正常に動作しますがフローティング アクション ボタンのメイン ページに戻ると、2 つのサブ ボタンがまだメインのフローティング ボタンの外側にある
修正するにはアプリを再度開く必要があります。
ここに私のコードがあります
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);
}
});
}