Checkbox checked or not cannot be logged












-1















I am an android learner, I have a task from my course to write into the log when a checkbox is clicked.
My XML is:



<CheckBox
android:id="@+id/whippedCreamCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="16sp"
android:paddingLeft ="24dp"
android:buttonTint="#008000"
android:textAppearance="?android:textAppearanceMedium" />


And corresponding java code is



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox);
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


The remaining code builds, runs and functions without errors. However, in the log I cannot see the desired output. But I see




Not supplying enough data to HAL, expected position 4798584 , only
wrote 4798080




You can access the entire log here https://gist.github.com/latrociny/f318f74bbf9b9e28cc0a3a5370eaf996










share|improve this question























  • when is this function called? on checkbox click?

    – ahuja007
    Nov 20 '18 at 16:44











  • No I did not create any other function to call this. Should I create another method to call this method?

    – Kay
    Nov 20 '18 at 16:50











  • You should call this function or otherwise how will you reach log printing statement

    – ahuja007
    Nov 20 '18 at 16:52
















-1















I am an android learner, I have a task from my course to write into the log when a checkbox is clicked.
My XML is:



<CheckBox
android:id="@+id/whippedCreamCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="16sp"
android:paddingLeft ="24dp"
android:buttonTint="#008000"
android:textAppearance="?android:textAppearanceMedium" />


And corresponding java code is



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox);
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


The remaining code builds, runs and functions without errors. However, in the log I cannot see the desired output. But I see




Not supplying enough data to HAL, expected position 4798584 , only
wrote 4798080




You can access the entire log here https://gist.github.com/latrociny/f318f74bbf9b9e28cc0a3a5370eaf996










share|improve this question























  • when is this function called? on checkbox click?

    – ahuja007
    Nov 20 '18 at 16:44











  • No I did not create any other function to call this. Should I create another method to call this method?

    – Kay
    Nov 20 '18 at 16:50











  • You should call this function or otherwise how will you reach log printing statement

    – ahuja007
    Nov 20 '18 at 16:52














-1












-1








-1








I am an android learner, I have a task from my course to write into the log when a checkbox is clicked.
My XML is:



<CheckBox
android:id="@+id/whippedCreamCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="16sp"
android:paddingLeft ="24dp"
android:buttonTint="#008000"
android:textAppearance="?android:textAppearanceMedium" />


And corresponding java code is



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox);
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


The remaining code builds, runs and functions without errors. However, in the log I cannot see the desired output. But I see




Not supplying enough data to HAL, expected position 4798584 , only
wrote 4798080




You can access the entire log here https://gist.github.com/latrociny/f318f74bbf9b9e28cc0a3a5370eaf996










share|improve this question














I am an android learner, I have a task from my course to write into the log when a checkbox is clicked.
My XML is:



<CheckBox
android:id="@+id/whippedCreamCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Whipped Cream"
android:textSize="16sp"
android:paddingLeft ="24dp"
android:buttonTint="#008000"
android:textAppearance="?android:textAppearanceMedium" />


And corresponding java code is



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox);
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


The remaining code builds, runs and functions without errors. However, in the log I cannot see the desired output. But I see




Not supplying enough data to HAL, expected position 4798584 , only
wrote 4798080




You can access the entire log here https://gist.github.com/latrociny/f318f74bbf9b9e28cc0a3a5370eaf996







android






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 16:36









KayKay

5311




5311













  • when is this function called? on checkbox click?

    – ahuja007
    Nov 20 '18 at 16:44











  • No I did not create any other function to call this. Should I create another method to call this method?

    – Kay
    Nov 20 '18 at 16:50











  • You should call this function or otherwise how will you reach log printing statement

    – ahuja007
    Nov 20 '18 at 16:52



















  • when is this function called? on checkbox click?

    – ahuja007
    Nov 20 '18 at 16:44











  • No I did not create any other function to call this. Should I create another method to call this method?

    – Kay
    Nov 20 '18 at 16:50











  • You should call this function or otherwise how will you reach log printing statement

    – ahuja007
    Nov 20 '18 at 16:52

















when is this function called? on checkbox click?

– ahuja007
Nov 20 '18 at 16:44





when is this function called? on checkbox click?

– ahuja007
Nov 20 '18 at 16:44













No I did not create any other function to call this. Should I create another method to call this method?

– Kay
Nov 20 '18 at 16:50





No I did not create any other function to call this. Should I create another method to call this method?

– Kay
Nov 20 '18 at 16:50













You should call this function or otherwise how will you reach log printing statement

– ahuja007
Nov 20 '18 at 16:52





You should call this function or otherwise how will you reach log printing statement

– ahuja007
Nov 20 '18 at 16:52












1 Answer
1






active

oldest

votes


















0














Add this attribute to the CheckBox:



android:onClick="indicateBoxChecked"


and change your code to this (it is inside your activity class isn't it?):



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = (CheckBox) v;
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


now whenever you click the CheckBox, the method indicateBoxChecked() will be executed.

I guess the variable TAG has been initialized.






share|improve this answer
























  • Can you please tell why did you not do CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox); ? yes it is inside activity class and TAG is initialized

    – Kay
    Nov 20 '18 at 17:00













  • @Kay so now you see the log message?

    – forpas
    Nov 20 '18 at 17:01











  • @Kay you don't need findViewById because the parameter v is the clicked View.

    – forpas
    Nov 20 '18 at 17:02











  • @Kay you just have to cast v to a CheckBox

    – forpas
    Nov 20 '18 at 17:03











  • hi this is fixed, thanks. I see now 2018-11-20 18:02:13.819 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true 2018-11-20 18:02:27.220 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is false 2018-11-20 18:02:28.943 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true

    – Kay
    Nov 20 '18 at 17:03











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397537%2fcheckbox-checked-or-not-cannot-be-logged%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Add this attribute to the CheckBox:



android:onClick="indicateBoxChecked"


and change your code to this (it is inside your activity class isn't it?):



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = (CheckBox) v;
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


now whenever you click the CheckBox, the method indicateBoxChecked() will be executed.

I guess the variable TAG has been initialized.






share|improve this answer
























  • Can you please tell why did you not do CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox); ? yes it is inside activity class and TAG is initialized

    – Kay
    Nov 20 '18 at 17:00













  • @Kay so now you see the log message?

    – forpas
    Nov 20 '18 at 17:01











  • @Kay you don't need findViewById because the parameter v is the clicked View.

    – forpas
    Nov 20 '18 at 17:02











  • @Kay you just have to cast v to a CheckBox

    – forpas
    Nov 20 '18 at 17:03











  • hi this is fixed, thanks. I see now 2018-11-20 18:02:13.819 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true 2018-11-20 18:02:27.220 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is false 2018-11-20 18:02:28.943 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true

    – Kay
    Nov 20 '18 at 17:03
















0














Add this attribute to the CheckBox:



android:onClick="indicateBoxChecked"


and change your code to this (it is inside your activity class isn't it?):



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = (CheckBox) v;
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


now whenever you click the CheckBox, the method indicateBoxChecked() will be executed.

I guess the variable TAG has been initialized.






share|improve this answer
























  • Can you please tell why did you not do CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox); ? yes it is inside activity class and TAG is initialized

    – Kay
    Nov 20 '18 at 17:00













  • @Kay so now you see the log message?

    – forpas
    Nov 20 '18 at 17:01











  • @Kay you don't need findViewById because the parameter v is the clicked View.

    – forpas
    Nov 20 '18 at 17:02











  • @Kay you just have to cast v to a CheckBox

    – forpas
    Nov 20 '18 at 17:03











  • hi this is fixed, thanks. I see now 2018-11-20 18:02:13.819 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true 2018-11-20 18:02:27.220 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is false 2018-11-20 18:02:28.943 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true

    – Kay
    Nov 20 '18 at 17:03














0












0








0







Add this attribute to the CheckBox:



android:onClick="indicateBoxChecked"


and change your code to this (it is inside your activity class isn't it?):



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = (CheckBox) v;
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


now whenever you click the CheckBox, the method indicateBoxChecked() will be executed.

I guess the variable TAG has been initialized.






share|improve this answer













Add this attribute to the CheckBox:



android:onClick="indicateBoxChecked"


and change your code to this (it is inside your activity class isn't it?):



public void indicateBoxChecked(View v) {
CheckBox whippedCreamCheckBox = (CheckBox) v;
boolean checked = whippedCreamCheckBox.isChecked();
Log.v(TAG, "Checkbox value is " + checked );
}


now whenever you click the CheckBox, the method indicateBoxChecked() will be executed.

I guess the variable TAG has been initialized.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 16:53









forpasforpas

11.1k3423




11.1k3423













  • Can you please tell why did you not do CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox); ? yes it is inside activity class and TAG is initialized

    – Kay
    Nov 20 '18 at 17:00













  • @Kay so now you see the log message?

    – forpas
    Nov 20 '18 at 17:01











  • @Kay you don't need findViewById because the parameter v is the clicked View.

    – forpas
    Nov 20 '18 at 17:02











  • @Kay you just have to cast v to a CheckBox

    – forpas
    Nov 20 '18 at 17:03











  • hi this is fixed, thanks. I see now 2018-11-20 18:02:13.819 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true 2018-11-20 18:02:27.220 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is false 2018-11-20 18:02:28.943 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true

    – Kay
    Nov 20 '18 at 17:03



















  • Can you please tell why did you not do CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox); ? yes it is inside activity class and TAG is initialized

    – Kay
    Nov 20 '18 at 17:00













  • @Kay so now you see the log message?

    – forpas
    Nov 20 '18 at 17:01











  • @Kay you don't need findViewById because the parameter v is the clicked View.

    – forpas
    Nov 20 '18 at 17:02











  • @Kay you just have to cast v to a CheckBox

    – forpas
    Nov 20 '18 at 17:03











  • hi this is fixed, thanks. I see now 2018-11-20 18:02:13.819 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true 2018-11-20 18:02:27.220 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is false 2018-11-20 18:02:28.943 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true

    – Kay
    Nov 20 '18 at 17:03

















Can you please tell why did you not do CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox); ? yes it is inside activity class and TAG is initialized

– Kay
Nov 20 '18 at 17:00







Can you please tell why did you not do CheckBox whippedCreamCheckBox = findViewById(R.id.whippedCreamCheckBox); ? yes it is inside activity class and TAG is initialized

– Kay
Nov 20 '18 at 17:00















@Kay so now you see the log message?

– forpas
Nov 20 '18 at 17:01





@Kay so now you see the log message?

– forpas
Nov 20 '18 at 17:01













@Kay you don't need findViewById because the parameter v is the clicked View.

– forpas
Nov 20 '18 at 17:02





@Kay you don't need findViewById because the parameter v is the clicked View.

– forpas
Nov 20 '18 at 17:02













@Kay you just have to cast v to a CheckBox

– forpas
Nov 20 '18 at 17:03





@Kay you just have to cast v to a CheckBox

– forpas
Nov 20 '18 at 17:03













hi this is fixed, thanks. I see now 2018-11-20 18:02:13.819 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true 2018-11-20 18:02:27.220 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is false 2018-11-20 18:02:28.943 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true

– Kay
Nov 20 '18 at 17:03





hi this is fixed, thanks. I see now 2018-11-20 18:02:13.819 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true 2018-11-20 18:02:27.220 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is false 2018-11-20 18:02:28.943 8019-8019/com.example.android.justjava V/MainActivity: Checkbox value is true

– Kay
Nov 20 '18 at 17:03


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397537%2fcheckbox-checked-or-not-cannot-be-logged%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$