CursorWheelLayout
CursorWheelLayout copied to clipboard
onItemSelected is not calling on selection
I am trying to make a spinning wheal for menu for that i use this library. The problem is this the onItemSelected function doesn't call. i tried log and toasting something in it but nothing happen. the Dashboard activity code is below:
`package tk.mahijat.login;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import github.hellocsl.cursorwheel.CursorWheelLayout;
import tk.mahijat.login.Adapter.WheelImageAdapter;
import tk.mahijat.login.Adapter.WheelTextAdapter;
import tk.mahijat.login.Data.ImageData;
import tk.mahijat.login.Data.MenuItemData;
public class dashboard extends AppCompatActivity implements CursorWheelLayout.OnMenuSelectedListener{
String useremail;
Button incomebtn;
Button expbtn;
Button brbtn;
Button reportbtn;
Button logout;
CursorWheelLayout wheel_text,wheel_image;
List<MenuItemData> lstText;
List<ImageData> lstImage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
Bundle extras = getIntent().getExtras();
if(extras == null) {
useremail= null;
} else {
useremail = extras.getString("useremail");
}
// incomebtn = (Button)findViewById(R.id.incomebtn);
// expbtn = (Button)findViewById(R.id.expensesbtn);
// brbtn = (Button)findViewById(R.id.borrowbtn);
// reportbtn = (Button)findViewById(R.id.reportbtn);
// logout = (Button)findViewById(R.id.logout);
//
// incomebtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// openincome(v);
// }
// });
// expbtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// openexpenses(v);
// }
// });
// brbtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// openborrow(v);
// }
// });
// reportbtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// openreport(v);
// }
// });
// logout.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// logoutuser(v);
// }
// });
initViews();
loadData();
}
private void loadData() {
lstText = new ArrayList<>();
lstText.add(new MenuItemData("DashBoard"));
lstText.add(new MenuItemData("Income"));
lstText.add(new MenuItemData("Expenses"));
lstText.add(new MenuItemData("Borrow"));
lstText.add(new MenuItemData("Report"));
lstText.add(new MenuItemData("User Profile"));
lstText.add(new MenuItemData("Logout"));
WheelTextAdapter adapter = new WheelTextAdapter(getBaseContext(),lstText);
wheel_text.setAdapter(adapter);
lstImage = new ArrayList<>();
lstImage.add(new ImageData(R.drawable.fb,"Facebook"));
lstImage.add(new ImageData(R.drawable.drive,"Drive"));
lstImage.add(new ImageData(R.drawable.windows,"Microsoft"));
lstImage.add(new ImageData(R.drawable.twitter,"Twitter"));
lstImage.add(new ImageData(R.drawable.income,"Income"));
WheelImageAdapter imgAdapter = new WheelImageAdapter(getBaseContext(),lstImage);
wheel_image.setAdapter(imgAdapter);
}
private void initViews() {
wheel_image = (CursorWheelLayout)findViewById(R.id.wheel_image);
wheel_text = (CursorWheelLayout)findViewById(R.id.wheel_text);
}
@Override
public void onItemSelected(CursorWheelLayout parent, View view, int pos) {
Log.e("Enter","Enter");
Toast.makeText(dashboard.this, "Enter in menu", Toast.LENGTH_SHORT).show();
if(parent.getId() == R.id.wheel_text)
Toast.makeText(dashboard.this, ""+lstText.get(pos).mTitle, Toast.LENGTH_SHORT).show();
if(lstText.get(pos).mTitle=="DashBoard")
{
}else if(lstText.get(pos).mTitle=="Income")
{
openincome(view);
}else if(lstText.get(pos).mTitle=="Expenses")
{
openexpenses(view);
}else if(lstText.get(pos).mTitle=="Borrow")
{
openborrow(view);
}else if(lstText.get(pos).mTitle=="Report")
{
openreport(view);
}else if(lstText.get(pos).mTitle=="User Profile")
{
}else if(lstText.get(pos).mTitle=="Logout")
{
logoutuser(view);
}
else if(parent.getId() == R.id.wheel_image)
Toast.makeText(getBaseContext(), "Selected"+lstImage.get(pos).imageDescription, Toast.LENGTH_SHORT).show();
}
public void logoutuser(View v) {
MyDBHandler dbHandler = new MyDBHandler(this, null, null, 1);
dbHandler.logoutuser(useremail);
Intent b = new Intent(this,Login.class);
startActivity(b);
}
public void openincome(View v)
{
Intent a = new Intent(this,income.class);
a.putExtra("useremail", useremail);
startActivity(a);
}
public void openexpenses(View v)
{
Intent a = new Intent(this,expenses.class);
a.putExtra("useremail",useremail);
startActivity(a);
}
public void openborrow(View v)
{
Intent a = new Intent(this,borrow.class);
a.putExtra("useremail",useremail);
startActivity(a);
}
public void openreport(View v)
{
Intent a = new Intent(this,report.class);
a.putExtra("useremail",useremail);
startActivity(a);
}
@Override
public void onBackPressed() {
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Closing Hisab-Kitab")
.setMessage("Are you sure you want to exit?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
System.exit(0);
}
})
.setNegativeButton("No", null)
.show();
}
}
`
If you need something more i'll provide you.