Float Action Menü Öğelerine tıklayınca yeni aktivity açma
07.01.2016 - 11:28
Bu resimdeki sol üst köşedeki float action buttonu projemde kullandım buraya kadar herşey güzel yalnız ben o papatya yapraklarına benziyen menü elemanlarının herbirine ayrı birer activity atamak istiyorum bu mümkün mü? Mümkünse bunu nasıl yapabilirim yani bir activitye nasıl bağlantı verebilirim? Aşağıda kod parçacığımı gönderdim nasıl bir ekleme yapılması gerekiyor yardımcı olan olursa çok sevinirim.
package info.androidhive.materialdesign;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton;
import com.oguzdev.circularfloatingactionmenu.library.FloatingActionMenu;
import com.oguzdev.circularfloatingactionmenu.library.SubActionButton;
import info.androidhive.mardinvalilik.R;
import info.androidhive.mardinvalilik.activity.Lan;
@SuppressWarnings("ALL")
public class Main2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
// Set up the large red button on the center right side
// With custom button and content sizes and margins
int redActionButtonSize = getResources().getDimensionPixelSize(R.dimen.kırmızı_butonun_pixel_boyutu); //Kırmızı butonun pixel boyutu
int redActionButtonMargin = getResources().getDimensionPixelOffset(R.dimen.action_button_margin); //Kırmızı butonun kenar pixel boyutu
int redActionButtonContentSize = getResources().getDimensionPixelSize(R.dimen.action_button_size);//Kırmızı butonun içindeki nesnenin pixel boyutu
int redActionButtonContentMargin = getResources().getDimensionPixelSize(R.dimen.action_button_size);//Kırmızı butonun içindeki nesnenin kenar pixel boyutu
int redActionMenuRadius = getResources().getDimensionPixelSize(R.dimen.action_button_size);//Menünün yarı çapı
int blueSubActionButtonSize = getResources().getDimensionPixelSize(R.dimen.action_button_size);// Menü elemanlarının buton boyutu
int blueSubActionButtonContentMargin = getResources().getDimensionPixelSize(R.dimen.action_button_size);//Menü elemanlarının içindeki nesnenin pixel boyutu
ImageView fabIconStar = new ImageView(this);
fabIconStar.setImageDrawable(getResources().getDrawable(R.drawable.ic_profile));
FloatingActionButton.LayoutParams starParams = new FloatingActionButton.LayoutParams(redActionButtonSize, redActionButtonSize);
starParams.setMargins(redActionButtonMargin,
redActionButtonMargin,
redActionButtonMargin,
redActionButtonMargin);
fabIconStar.setLayoutParams(starParams);
FloatingActionButton.LayoutParams fabIconStarParams = new FloatingActionButton.LayoutParams(redActionButtonContentSize, redActionButtonContentSize);
fabIconStarParams.setMargins(redActionButtonContentMargin,
redActionButtonContentMargin,
redActionButtonContentMargin,
redActionButtonContentMargin);
final FloatingActionButton leftCenterButton = new FloatingActionButton.Builder(this)
.setContentView(fabIconStar, fabIconStarParams)
.setBackgroundDrawable(R.drawable.fab_background)
.setPosition(FloatingActionButton.POSITION_BOTTOM_CENTER)
.setLayoutParams(starParams)
.build();
// Set up customized SubActionButtons for the right center menu
SubActionButton.Builder lCSubBuilder = new SubActionButton.Builder(this);
lCSubBuilder.setBackgroundDrawable(getResources().getDrawable(R.drawable.button_action_dark_selector));
FrameLayout.LayoutParams blueContentParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
blueContentParams.setMargins(blueSubActionButtonContentMargin,
blueSubActionButtonContentMargin,
blueSubActionButtonContentMargin,
blueSubActionButtonContentMargin);
lCSubBuilder.setLayoutParams(blueContentParams);
// Set custom layout params
FrameLayout.LayoutParams blueParams = new FrameLayout.LayoutParams(blueSubActionButtonSize, blueSubActionButtonSize);
lCSubBuilder.setLayoutParams(blueParams);
ImageView lcIcon1 = new ImageView(this);
ImageView lcIcon2 = new ImageView(this);
ImageView lcIcon3 = new ImageView(this);
ImageView lcIcon4 = new ImageView(this);
ImageView lcIcon5 = new ImageView(this);
lcIcon1.setImageDrawable(getResources().getDrawable(R.drawable.button_action_dark));
lcIcon2.setImageDrawable(getResources().getDrawable(R.drawable.button_action_dark));
lcIcon3.setImageDrawable(getResources().getDrawable(R.drawable.button_action_dark));
lcIcon4.setImageDrawable(getResources().getDrawable(R.drawable.button_action_dark));
lcIcon5.setImageDrawable(getResources().getDrawable(R.drawable.button_action_dark));
// Build another menu with custom options
final FloatingActionMenu leftCenterMenu = new FloatingActionMenu.Builder(this)
.addSubActionView(lCSubBuilder.setContentView(lcIcon1, blueContentParams).build())
.addSubActionView(lCSubBuilder.setContentView(lcIcon2, blueContentParams).build())
.addSubActionView(lCSubBuilder.setContentView(lcIcon3, blueContentParams).build())
.addSubActionView(lCSubBuilder.setContentView(lcIcon4, blueContentParams).build())
.addSubActionView(lCSubBuilder.setContentView(lcIcon5, blueContentParams).build())
.setRadius(redActionMenuRadius)
.setStartAngle(150)
.setEndAngle(-150)
.attachTo(leftCenterButton)
.build();
80
Görüntülenme
0 Beğeni