Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6562197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:40:50+00:00 2026-05-25T13:40:50+00:00

I have another problem. I defined CheckBoxes in layout and I’m getting their state

  • 0

I have another problem. I defined CheckBoxes in layout and I’m getting their state with isChecked() method in a class. However I’m getting an error whenever this method is called with the following error log:

09-05 14:55:58.457: ERROR/AndroidRuntime(582): FATAL EXCEPTION: main
09-05 14:55:58.457: ERROR/AndroidRuntime(582): java.lang.IllegalStateException: Could not execute method of the activity
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at android.view.View$1.onClick(View.java:2144)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at android.view.View.performClick(View.java:2485)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at android.view.View$PerformClick.run(View.java:9080)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at android.os.Handler.handleCallback(Handler.java:587)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at android.os.Looper.loop(Looper.java:123)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at android.app.ActivityThread.main(ActivityThread.java:3683)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at java.lang.reflect.Method.invokeNative(Native Method)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at java.lang.reflect.Method.invoke(Method.java:507)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at dalvik.system.NativeStart.main(Native Method)
09-05 14:55:58.457: ERROR/AndroidRuntime(582): Caused by: java.lang.reflect.InvocationTargetException
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at java.lang.reflect.Method.invokeNative(Native Method)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at java.lang.reflect.Method.invoke(Method.java:507)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at android.view.View$1.onClick(View.java:2139)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     ... 11 more
09-05 14:55:58.457: ERROR/AndroidRuntime(582): Caused by: java.lang.NullPointerException
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     at alesito.WorkingHoursLogger.zapolniDelavnike.shraniUrnik(zapolniDelavnike.java:88)
09-05 14:55:58.457: ERROR/AndroidRuntime(582):     ... 14 more

This is class code:

private DatabaseAdapter dbOperator;
private Cursor cursor;
private static final String TABLE_NAME = "hours";
public static final String COL_ROWID = "_id";
public static final String COL_DATE = "date";
public static final String COL_DATE_TYPE = "dateType";
public static final String COL_DEF_HOURS = "defaultHours";
public static final String COL_COR_HOURS = "correctionHours";
public static final String COL_OPOMBA = "opomba";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dnevi);
    dbOperator = new DatabaseAdapter(this);
    dbOperator.open();

}
public void zapolniDni(View view){
    setContentView(R.layout.zapolni);
}
public void shraniUrnik(View view) throws ParseException{
    DatePicker zacetniDatumPicker = (DatePicker)findViewById(R.id.zacetniDatum);
    DatePicker koncniDatumPicker = (DatePicker)findViewById(R.id.koncniDatum);


    TimePicker zacetniUraPicker = (TimePicker)findViewById(R.id.zacetnaUra);
    Time zacetnaUra = new Time();
    zacetnaUra.set(0, zacetniUraPicker.getCurrentMinute(), zacetniUraPicker.getCurrentHour(), 0, 0, 0);

    TimePicker koncniUraPicker = (TimePicker)findViewById(R.id.koncnaUra);
    Time koncnaUra = new Time();
    koncnaUra.set(0, koncniUraPicker.getCurrentMinute(), koncniUraPicker.getCurrentHour(), 0, 0, 0);

    double razlika = 0;
    if (Time.compare(zacetnaUra, koncnaUra) < 0){
        double zacetniCas = zacetnaUra.hour * 60 + zacetnaUra.minute;
        double koncniCas = koncnaUra.hour * 60 + koncnaUra.minute;
        razlika = (koncniCas - zacetniCas) / 60;
    }

    CheckBox ponedeljek = (CheckBox)findViewById(R.id.ponedeljek);
    CheckBox torek = (CheckBox)findViewById(R.id.torek);
    CheckBox sreda = (CheckBox)findViewById(R.id.sreda);
    CheckBox cetrtek = (CheckBox)findViewById(R.id.cetrtek);
    CheckBox petek = (CheckBox)findViewById(R.id.petek);
    CheckBox sobota = (CheckBox)findViewById(R.id.sobota);
    CheckBox nedelja = (CheckBox)findViewById(R.id.nedelja);


    GregorianCalendar gcal = new GregorianCalendar();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy.M.d");
    Date startDate = sdf.parse(zacetniDatumPicker.getYear()+"."+ (zacetniDatumPicker.getMonth()+1)+"."+ zacetniDatumPicker.getDayOfMonth());
    Date endDate = sdf.parse(koncniDatumPicker.getYear()+"."+ (koncniDatumPicker.getMonth()+1)+"."+ (koncniDatumPicker.getDayOfMonth()+1));


    gcal.setTime(startDate);
    while (gcal.getTime().before(endDate)){
        switch (gcal.getTime().getDay()){
            case 0:
                if (nedelja.isChecked()){
                    dbOperator.createDay(Integer.toString(gcal.getTime().getYear())+Integer.toString((gcal.getTime().getMonth()+1))+Integer.toString(gcal.getTime().getDate()), gcal.getTime().toString(), razlika, 0.0, "");
                }
            case 1:
                if (ponedeljek.isChecked()){
                    dbOperator.createDay(Integer.toString(gcal.getTime().getYear())+Integer.toString((gcal.getTime().getMonth()+1))+Integer.toString(gcal.getTime().getDate()), gcal.getTime().toString(), razlika, 0.0, "");
                }
            case 2:
                if (torek.isChecked()){
                    dbOperator.createDay(Integer.toString(gcal.getTime().getYear())+Integer.toString((gcal.getTime().getMonth()+1))+Integer.toString(gcal.getTime().getDate()), gcal.getTime().toString(), razlika, 0.0, "");
                }
            case 3:
                if (sreda.isChecked()){
                    dbOperator.createDay(Integer.toString(gcal.getTime().getYear())+Integer.toString((gcal.getTime().getMonth()+1))+Integer.toString(gcal.getTime().getDate()), gcal.getTime().toString(), razlika, 0.0, "");
                }
            case 4:
                if (cetrtek.isChecked()){
                    dbOperator.createDay(Integer.toString(gcal.getTime().getYear())+Integer.toString((gcal.getTime().getMonth()+1))+Integer.toString(gcal.getTime().getDate()), gcal.getTime().toString(), razlika, 0.0, "");
                }
            case 5:
                if (petek.isChecked()){
                    dbOperator.createDay(Integer.toString(gcal.getTime().getYear())+Integer.toString((gcal.getTime().getMonth()+1))+Integer.toString(gcal.getTime().getDate()), gcal.getTime().toString(), razlika, 0.0, "");
                }
            case 6:
                if (sobota.isChecked()){
                    dbOperator.createDay(Integer.toString(gcal.getTime().getYear())+Integer.toString((gcal.getTime().getMonth()+1))+Integer.toString(gcal.getTime().getDate()), gcal.getTime().toString(), razlika, 0.0, "");
                }
            default:
                Toast nicOznaceno = Toast.makeText(this, "nič ni označeno", Toast.LENGTH_LONG);
                nicOznaceno.show();
        }
        gcal.add(gcal.DAY_OF_YEAR, 1);
    }
}

And this is layout file:

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="">
    <TextView 
        android:id="@+id/navodiloDnevi"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:text="@string/navodiloDnevi"/>
    <CheckBox 
        android:id="@+id/ponedeljek"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/navodiloDnevi"
        android:text="@string/ponedeljek"/>
    <CheckBox 
        android:id="@+id/torek"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/ponedeljek"
        android:text="@string/torek"/>
    <CheckBox 
        android:id="@+id/sreda"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/torek"
        android:text="@string/sreda"/>
    <CheckBox 
        android:id="@+id/cetrtek"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/sreda"
        android:text="@string/cetrtek"/>
    <CheckBox 
        android:id="@+id/petek"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/cetrtek"
        android:text="@string/petek"/>
    <CheckBox 
        android:id="@+id/sobota"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/petek"
        android:text="@string/sobota"/>
    <CheckBox 
        android:id="@+id/nedelja"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/sobota"
        android:text="@string/nedelja"/>
    <Button
        android:id="@+id/posljiIzbraneDni"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/posljiIzbraneDni"
        android:onClick="zapolniDni"
        android:layout_below="@id/nedelja"
        android:layout_centerHorizontal="true"/>
</RelativeLayout>

Why am I getting the errors?

EDIT:

Ok, I’ll specify further. The class that has the source up there calls two layouts. The first layout that is called (R.layout.dnevi) contains the checkboxes (attached xml source). When checking is done and button is clicked, the next method in the class is executed which shows a new layout (R.layout.zapolni). This one doesn’t contain any checkboxes but it uses the data (checked/unchecked) from the first layout (R.layout.dnevi). Hope this helps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:40:50+00:00Added an answer on May 25, 2026 at 1:40 pm

    Well I found a solution since nothing that I found on web helped.
    I created separate activities for both layouts and I put isChecked status in Intent with putExtra().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After getting a helpful answer here , I have run into yet another problem:
Here's my problem: I have a virtual method defined in a .h file that
Following on from a question I posted yesterday about GUIs, I have another problem
I've been struggling with Zend_Navigation all weekend, and now I have another problem, which
Okay, so I have another question on a prolog homework problem I am struggling
another ordered delivery problem. We have an orchestration which is bound to a send
here is the problem. I have one PC using VS2008 (SP1 ) and another
I am facing a weird problem I have defined I a structure in a
I have 4 classes, one Database helper and 3 defined like this: abstract class
Is it possible to have a manifest defined based on another manifest in Scala?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.