我正在使用Hitomis/CircleMenu在onclick上显示社交媒体图标和对其他活动的意图。
它适用于烘烤子菜单值,但意图仅在开始时工作。当动画开始时,活动意图到另一个。我想显示整个动画,然后想要另一个活动。
这是我的代码
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CircleMenu circleMenu = (CircleMenu) findViewById(R.id.circle_menu);
circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.mipmap.ic_launcher, R.mipmap.ic_launcher);
circleMenu.addSubMenu(Color.parseColor("#258CFF"), R.mipmap.ic_launcher)
.addSubMenu(Color.parseColor("#30A400"), R.mipmap.ic_launcher)
.addSubMenu(Color.parseColor("#FF4B32"), R.mipmap.ic_launcher)
.addSubMenu(Color.parseColor("#8A39FF"), R.mipmap.ic_launcher)
.addSubMenu(Color.parseColor("#FF6A00"), R.mipmap.ic_launcher);
circleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {
@Override
public void onMenuSelected(int index) {
switch (index) {
case 0:
Intent intent = new Intent(MainActivity.this,Jude.class);
startActivity(intent);
break;
case 1:
Intent intent2 = new Intent(MainActivity.this,Jude.class);
startActivity(intent2);
break;
case 2:
Intent inten3 = new Intent(MainActivity.this,Jude.class);
startActivity(inten3);
break;
case 3:
Toast.makeText(MainActivity.this, "Settings button Clcked", Toast.LENGTH_SHORT).show();
break;
case 4:
Toast.makeText(MainActivity.this, "GPS button Clicked", Toast.LENGTH_SHORT).show();
break;
}
}
}
);
circleMenu.setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {
@Override
public void onMenuOpened() {
Toast.makeText(MainActivity.this, "Menu Opend", Toast.LENGTH_SHORT).show();
}
@Override
public void onMenuClosed() {
Toast.makeText(MainActivity.this, "Menu Closed", Toast.LENGTH_SHORT).show();
}
}
);
}
}
答案 0 :(得分:1)
要查看完整动画,您需要更改代码,如下所示:
第1步:在课程中声明一个变量
int selectedIndex;
第2步:在MenuSelectedListener中保存变量中的所选索引
circleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {
@Override
public void onMenuSelected(int index) {
selectedIndex=index; }
}
);
第3步:处理菜单关闭事件
circleMenu.setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {
@Override
public void onMenuOpened() {
}
@Override
public void onMenuClosed() {
if(selectedIndex==3)
startActivity(new Intent(MainActivity.this, ThankYouActivity.class));
// or use Switch case
}
}
);
希望这会对你有所帮助 感谢
答案 1 :(得分:1)
编辑答案:Appeteria
在类
中声明一个变量int selectedIndex;
mCircleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {
@Override
public void onMenuSelected(int index) {
switch (index) { /* 0 is for close menu...*/
case 0:
selectedIndex = 1;
break;
case 1:
selectedIndex = 2;
break;
case 2:
selectedIndex = 3;
break;
}
}
});
<强> ...和... 强>
mCircleMenu.setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {
@Override
public void onMenuOpened() {
selectedIndex = 0;
}
@Override
public void onMenuClosed() {
switch (selectedIndex) {
case 1:
Intent intent1 = new Intent(ThisActivity.this, Activity1.class);
startActivity(intent1);
break;
case 2:
Intent intent2 = new Intent(ThisActivity.this, Activity2.class);
startActivity(intent2);
break;
}
}
});
答案 2 :(得分:0)
我认为你使用的是Hitomis / CircleMenu -gradle文件,只需使用cmllibrary就可以获得Hitomis / CircleMenu的源代码并打开CircleMenu类,你可以更改动画和onclick事件。