2

the onclicklistener is not at all working while clicking

public void adddata()
{
    subbtn.setOnClickListener(new View.OnClickListener()
        {public void onClick(View v) {
            Date d = new Date(); 
            CharSequence s = DateFormat.format("MMMM d, yyyy ", d.getTime());
            int total = Integer.parseInt(String.valueOf(foodtext.getText())) + Integer.parseInt(petroltext.getText().toString()) + Integer.parseInt(grocetext.getText().toString()) +
                    Integer.parseInt(sundrytext.getText().toString()) + Integer.parseInt(educatext.getText().toString()) + Integer.parseInt(loantext.getText().toString());
            System.out.println(total);
            boolean inserted = dbex.insertdata(Integer.parseInt(s.toString()), Integer.parseInt(foodtext.getText().toString()), Integer.parseInt(petroltext.getText().toString()), Integer.parseInt(grocetext.getText().toString()),
                    Integer.parseInt(sundrytext.getText().toString()), Integer.parseInt(educatext.getText().toString()), Integer.parseInt(loantext.getText().toString()), total);
            if (inserted)
                   Toast.makeText(todayex.this, "datainserted", Toast.LENGTH_LONG).show();


            else
                Toast.makeText(todayex.this, "datanotinserted", Toast.LENGTH_LONG).show();
        }});
        startActivity(intent);

    }
}

while clicking that button it needs to open new activity as well should store my data into database

xashru
  • 3,400
  • 2
  • 17
  • 30
  • Is it related to Java Swing or Eclipse SWT ? – Sambit May 18 '19 at 15:16
  • If it is related to Android, you can check this https://stackoverflow.com/questions/25803727/android-setonclicklistener-method-how-does-it-work – Sambit May 18 '19 at 15:21

0 Answers0