Open marcoazeem opened 6 years ago
hi you can use this: private int indexitem=-1; ... circleMenu = (CircleMenu) findViewById(R.id.circle_menu);
circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.drawable.ic_menu_white_24dp, R.drawable.ic_close_white_24dp)
.addSubMenu(Color.parseColor("#258CFF"), R.drawable.ic_category_white_24dp)
.addSubMenu(Color.parseColor("#30A400"), R.drawable.search)
.addSubMenu(Color.parseColor("#FF4B32"), R.drawable.ic_notifications_white_24dp)
.setOnMenuSelectedListener(new OnMenuSelectedListener() {
@Override
public void onMenuSelected(int index) {
indexitem=index;
}
}).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {
@Override
public void onMenuOpened() {}
@Override
public void onMenuClosed() {
switch (indexitem) {
case 0:
indexitem=-1;
Intent intent = new Intent(context, SearchResultChannelActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("tb_category_id", 0);
intent.putExtra("tb_category_title", "دسته بندی");
startActivity(intent);
break;
case 1:
indexitem=-1;
//do something
break;
case 2:
indexitem=-1;
//do something
break;
}
}
});
is it working fine @marcoazeem ? any tips for me? how did you get it worked out??
Hi yeah I got it working, I used a
Handler setDelay; Runnable startDelay;
//Activity Delay setDelay = new Handler();
//Circle Menu Code
circleMenu = (CircleMenu) findViewById(R.id.circle_menu);
circleMenu.setMainMenu(Color.parseColor("#c02f34"),
R.mipmap.icon_menu, R.mipmap.icon_cancel); circleMenu.addSubMenu(Color.parseColor("#c02f34"), R.mipmap.locationwhite) .addSubMenu(Color.parseColor("#c02f34"), R.mipmap.calculatorwhite) .addSubMenu(Color.parseColor("#c02f34"), R.mipmap.globewhite) .addSubMenu(Color.parseColor("#c02f34"), R.mipmap.account);
circleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {
@Override
public void
onMenuSelected(int index) { switch (index) { case 0: startDelay = new Runnable() { @Override public void run() {
startActivity(new Intent(Circle.this, track.class)); } };
setDelay.postDelayed(startDelay, 800); break; case 1: startDelay = new Runnable() { @Override public void run() {
startActivity(new Intent(Circle.this, calc.class)); } };
setDelay.postDelayed(startDelay, 800);
On Fri, Dec 21, 2018, 09:13 sanjum01 <notifications@github.com wrote:
is it working fine @marcoazeem https://github.com/marcoazeem ? any tips for me? how did you get it worked out??
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Hitomis/CircleMenu/issues/25#issuecomment-449240624, or mute the thread https://github.com/notifications/unsubscribe-auth/AlSUWR1eQJzZs8iowQYuwR2Q5LTGXWE0ks5u7F_zgaJpZM4T3BFi .
Thanks for your comment bro, does each icon on the circle menu leads to new activity connected to that icon? I tried to link one activity with one of the icon by using above code, but its not initiating new activity.. here is the code package com.example.sanju.circlefinal;
import android.content.Intent; import android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast;
import com.hitomi.cmlibrary.CircleMenu; import com.hitomi.cmlibrary.OnMenuSelectedListener; import com.hitomi.cmlibrary.OnMenuStatusChangeListener;
public class MainActivity extends AppCompatActivity { CircleMenu circleMenu; private int indexitem=-1;
String arrayName[]={"Facebook",
"Twitter",
"Youtube",
"Windows",
"Drive"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// private int indexitem =-1;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CircleMenu circleMenu = (CircleMenu) findViewById(R.id.circle_menu);
circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.drawable.ic_add, R.drawable.ic_remove)
.addSubMenu(Color.parseColor("#258CFF"), R.drawable.ic_facebook)
.addSubMenu(Color.parseColor("#6d4c41"), R.drawable.ic_twitter)
.addSubMenu(Color.parseColor("#ff0000"), R.drawable.ic_youtube)
.addSubMenu(Color.parseColor("#03a9f4"), R.drawable.ic_windows)
.addSubMenu(Color.parseColor("#1a237e"), R.drawable.ic_drive)
.setOnMenuSelectedListener(new OnMenuSelectedListener() {
//@Override
// public void onMenuSelected(int index) {
// Toast.makeText(MainActivity.this, "You selected" + arrayName[index], Toast.LENGTH_LONG).show();
/*public void onClick(View v);
{
Intent i = new Intent(this,fbActivity.class);
startActivity(i);
}
}
@Override
public void onBackPressed() {
if (circleMenu.isOpened())
circleMenu.closeMenu();
else
finish();
}*/
@Override
public void onMenuSelected(int index) {
}
}).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {
@Override
public void onMenuOpened() {
}
@Override
public void onMenuClosed() {
switch (indexitem) {
case 0:
indexitem = -1;
Intent intent = new Intent(MainActivity.this, fbActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("tb_category_id", 0);
intent.putExtra("tb_category_title", "دسته بندی");
startActivity(intent);
break;
case 1:
indexitem = -1;
/* //do something
Intent intent = new Intent(MainActivity.this, ytActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("tb_category_id", 0);
intent.putExtra("tb_category_title", "دسته بندی");
startActivity(intent);*/
break;
case 2:
indexitem = -1;
//do something
break;
}
}
});
}}
package com.example.sanju.circlefinal;
import android.support.v7.app.AppCompatActivity; import android.os.Bundle;
public class fbActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fb);
}
}
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".fbActivity">
<TextView
android:id="@+id/tvFacebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="you are in fb activity now"
tools:layout_editor_absoluteX="163dp"
tools:layout_editor_absoluteY="122dp" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".fbActivity">
<TextView android:id="@+id/tvFacebook" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="you are in fb activity now" tools:layout_editor_absoluteX="163dp" tools:layout_editor_absoluteY="122dp" />
</android.support.constraint.ConstraintLayout>
`public class Circle extends AppCompatActivity {
CircleMenu circleMenu;
Handler setDelay;
Runnable startDelay;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_circle);
//Activity Delay
setDelay = new Handler();
//Circle Menu Code
circleMenu = (CircleMenu) findViewById(R.id.circle_menu);
circleMenu.setMainMenu(Color.parseColor("#c02f34"), R.mipmap.icon_menu, R.mipmap.icon_cancel);
circleMenu.addSubMenu(Color.parseColor("#c02f34"), R.mipmap.locationwhite)
.addSubMenu(Color.parseColor("#c02f34"), R.mipmap.calculatorwhite)
.addSubMenu(Color.parseColor("#c02f34"), R.mipmap.globewhite)
.addSubMenu(Color.parseColor("#c02f34"), R.mipmap.account);
//OnClickListener
circleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {
@Override
public void onMenuSelected(int index) {
switch (index) {
case 0:
startDelay = new Runnable() {
@Override
public void run() {
startActivity(new Intent(Circle.this, track.class)); //this opens new activity
}
};
//this sets delay so that the circle goes around fully setDelay.postDelayed(startDelay, 800); break; case 1: startDelay = new Runnable() { @Override public void run() { startActivity(new Intent(Circle.this, calc.class)); } }; setDelay.postDelayed(startDelay, 800);`
With this the circle does not turn fully, it turns half way and open the new activity. how would I solve the issue?
circleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {