Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onItemSelected is not calling on selection #13

Open
mahipaljyani opened this issue Jun 17, 2018 · 0 comments
Open

onItemSelected is not calling on selection #13

mahipaljyani opened this issue Jun 17, 2018 · 0 comments

Comments

@mahipaljyani
Copy link

mahipaljyani commented Jun 17, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant