Using if statement to load a list before sending it via intent - sending 3 times The Next CEO of Stack OverflowCross-thread operation not valid: Control accessed from a thread other than the thread it was created onURL Encoding using C#Populate XDocument from StringSend Email via C# through Google Apps accountPassing arguments to C# generic new() of templated typeSqlException from Entity Framework - New transaction is not allowed because there are other threads running in the sessionWCF vs ASP.NET Web APIWhy not inherit from List<T>?Send List of Parcelable Object Inside Parcelable Object to Another Activity Using IntentExtract the list of all extras from an Intent in Xamarin.Android and save it in a dictionary

How to write the block matrix in LaTex?

Grabbing quick drinks

Science fiction (dystopian) short story set after WWIII

Why is there a PLL in CPU?

Unreliable Magic - Is it worth it?

Only print output after finding pattern

How to start emacs in "nothing" mode (`fundamental-mode`)

Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?

If the heap is initialized for security, then why is the stack uninitialized?

Natural language into sentence logic

Fastest way to shutdown Ubuntu Mate 18.10

What happens if you roll doubles 3 times then land on "Go to jail?"

Where to find order of arguments for default functions

Is HostGator storing my password in plaintext?

Robert Sheckley short story about vacation spots being overwhelmed

Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables

What can we do to stop prior company from asking us questions?

If I blow insulation everywhere in my attic except the door trap, will heat escape through it?

Should I tutor a student who I know has cheated on their homework?

Why do professional authors make "consistency" mistakes? And how to avoid them?

How to get regions to plot as graphics

How to safely derail a train during transit?

How to Reset Passwords on Multiple Websites Easily?

Need some help with wall behind rangetop



Using if statement to load a list before sending it via intent - sending 3 times



The Next CEO of Stack OverflowCross-thread operation not valid: Control accessed from a thread other than the thread it was created onURL Encoding using C#Populate XDocument from StringSend Email via C# through Google Apps accountPassing arguments to C# generic new() of templated typeSqlException from Entity Framework - New transaction is not allowed because there are other threads running in the sessionWCF vs ASP.NET Web APIWhy not inherit from List<T>?Send List of Parcelable Object Inside Parcelable Object to Another Activity Using IntentExtract the list of all extras from an Intent in Xamarin.Android and save it in a dictionary










0















Im trying to use if statements to load a list later send it via intent, it seems to be sending it 3 times or looping through to load the string 3 times. I have to send 2 intents to the consuming activity. Can someone help me?










share|improve this question



















  • 2





    Where is this code executed? Could you be adding the same delegate three times?

    – D Stanley
    Mar 21 at 16:42











  • You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.

    – Wayne Feltham
    Mar 21 at 16:43











  • I have debugged and it is looping 3 times before sending the intent.

    – DavidMc
    Mar 21 at 16:46











  • Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.

    – Wayne Feltham
    Mar 21 at 16:55











  • I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?

    – Wayne Feltham
    Mar 21 at 17:02















0















Im trying to use if statements to load a list later send it via intent, it seems to be sending it 3 times or looping through to load the string 3 times. I have to send 2 intents to the consuming activity. Can someone help me?










share|improve this question



















  • 2





    Where is this code executed? Could you be adding the same delegate three times?

    – D Stanley
    Mar 21 at 16:42











  • You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.

    – Wayne Feltham
    Mar 21 at 16:43











  • I have debugged and it is looping 3 times before sending the intent.

    – DavidMc
    Mar 21 at 16:46











  • Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.

    – Wayne Feltham
    Mar 21 at 16:55











  • I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?

    – Wayne Feltham
    Mar 21 at 17:02













0












0








0








Im trying to use if statements to load a list later send it via intent, it seems to be sending it 3 times or looping through to load the string 3 times. I have to send 2 intents to the consuming activity. Can someone help me?










share|improve this question
















Im trying to use if statements to load a list later send it via intent, it seems to be sending it 3 times or looping through to load the string 3 times. I have to send 2 intents to the consuming activity. Can someone help me?







c# xamarin.android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 22:06







DavidMc

















asked Mar 21 at 16:36









DavidMcDavidMc

42




42







  • 2





    Where is this code executed? Could you be adding the same delegate three times?

    – D Stanley
    Mar 21 at 16:42











  • You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.

    – Wayne Feltham
    Mar 21 at 16:43











  • I have debugged and it is looping 3 times before sending the intent.

    – DavidMc
    Mar 21 at 16:46











  • Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.

    – Wayne Feltham
    Mar 21 at 16:55











  • I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?

    – Wayne Feltham
    Mar 21 at 17:02












  • 2





    Where is this code executed? Could you be adding the same delegate three times?

    – D Stanley
    Mar 21 at 16:42











  • You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.

    – Wayne Feltham
    Mar 21 at 16:43











  • I have debugged and it is looping 3 times before sending the intent.

    – DavidMc
    Mar 21 at 16:46











  • Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.

    – Wayne Feltham
    Mar 21 at 16:55











  • I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?

    – Wayne Feltham
    Mar 21 at 17:02







2




2





Where is this code executed? Could you be adding the same delegate three times?

– D Stanley
Mar 21 at 16:42





Where is this code executed? Could you be adding the same delegate three times?

– D Stanley
Mar 21 at 16:42













You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.

– Wayne Feltham
Mar 21 at 16:43





You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.

– Wayne Feltham
Mar 21 at 16:43













I have debugged and it is looping 3 times before sending the intent.

– DavidMc
Mar 21 at 16:46





I have debugged and it is looping 3 times before sending the intent.

– DavidMc
Mar 21 at 16:46













Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.

– Wayne Feltham
Mar 21 at 16:55





Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.

– Wayne Feltham
Mar 21 at 16:55













I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?

– Wayne Feltham
Mar 21 at 17:02





I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?

– Wayne Feltham
Mar 21 at 17:02












2 Answers
2






active

oldest

votes


















0














Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.






share|improve this answer























  • Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical

    – Gibbon
    Mar 21 at 16:49


















0














Not sure why it's happening but this might work around it until you can figure it out.



// global variable
var running = false;

btn.Click += delegate


if (!running)

running = true;

if (ckb1.Checked)

Items.Add("Regretful");

if (ckb2.Checked)

Items.Add("Empathic");

if (ckb3.Checked)

Items.Add("Shocked");

if (ckb4.Checked)

Items.Add("Shy");

if (ckb5.Checked)

Items.Add("Irritated");

if (ckb6.Checked)

Items.Add("Lazy");



string result = string.Join(",", Items.ToArray());

var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);

running = false;



;
c# xamarin.android
shareeditflag





share|improve this answer























  • Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.

    – Wayne Feltham
    Mar 21 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%2f55285234%2fusing-if-statement-to-load-a-list-before-sending-it-via-intent-sending-3-times%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.






share|improve this answer























  • Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical

    – Gibbon
    Mar 21 at 16:49















0














Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.






share|improve this answer























  • Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical

    – Gibbon
    Mar 21 at 16:49













0












0








0







Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.






share|improve this answer













Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 21 at 16:42









WazzieWazzie

300413




300413












  • Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical

    – Gibbon
    Mar 21 at 16:49

















  • Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical

    – Gibbon
    Mar 21 at 16:49
















Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical

– Gibbon
Mar 21 at 16:49





Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical

– Gibbon
Mar 21 at 16:49













0














Not sure why it's happening but this might work around it until you can figure it out.



// global variable
var running = false;

btn.Click += delegate


if (!running)

running = true;

if (ckb1.Checked)

Items.Add("Regretful");

if (ckb2.Checked)

Items.Add("Empathic");

if (ckb3.Checked)

Items.Add("Shocked");

if (ckb4.Checked)

Items.Add("Shy");

if (ckb5.Checked)

Items.Add("Irritated");

if (ckb6.Checked)

Items.Add("Lazy");



string result = string.Join(",", Items.ToArray());

var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);

running = false;



;
c# xamarin.android
shareeditflag





share|improve this answer























  • Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.

    – Wayne Feltham
    Mar 21 at 17:03















0














Not sure why it's happening but this might work around it until you can figure it out.



// global variable
var running = false;

btn.Click += delegate


if (!running)

running = true;

if (ckb1.Checked)

Items.Add("Regretful");

if (ckb2.Checked)

Items.Add("Empathic");

if (ckb3.Checked)

Items.Add("Shocked");

if (ckb4.Checked)

Items.Add("Shy");

if (ckb5.Checked)

Items.Add("Irritated");

if (ckb6.Checked)

Items.Add("Lazy");



string result = string.Join(",", Items.ToArray());

var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);

running = false;



;
c# xamarin.android
shareeditflag





share|improve this answer























  • Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.

    – Wayne Feltham
    Mar 21 at 17:03













0












0








0







Not sure why it's happening but this might work around it until you can figure it out.



// global variable
var running = false;

btn.Click += delegate


if (!running)

running = true;

if (ckb1.Checked)

Items.Add("Regretful");

if (ckb2.Checked)

Items.Add("Empathic");

if (ckb3.Checked)

Items.Add("Shocked");

if (ckb4.Checked)

Items.Add("Shy");

if (ckb5.Checked)

Items.Add("Irritated");

if (ckb6.Checked)

Items.Add("Lazy");



string result = string.Join(",", Items.ToArray());

var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);

running = false;



;
c# xamarin.android
shareeditflag





share|improve this answer













Not sure why it's happening but this might work around it until you can figure it out.



// global variable
var running = false;

btn.Click += delegate


if (!running)

running = true;

if (ckb1.Checked)

Items.Add("Regretful");

if (ckb2.Checked)

Items.Add("Empathic");

if (ckb3.Checked)

Items.Add("Shocked");

if (ckb4.Checked)

Items.Add("Shy");

if (ckb5.Checked)

Items.Add("Irritated");

if (ckb6.Checked)

Items.Add("Lazy");



string result = string.Join(",", Items.ToArray());

var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);

running = false;



;
c# xamarin.android
shareeditflag






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 21 at 16:53









Wayne FelthamWayne Feltham

466313




466313












  • Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.

    – Wayne Feltham
    Mar 21 at 17:03

















  • Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.

    – Wayne Feltham
    Mar 21 at 17:03
















Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.

– Wayne Feltham
Mar 21 at 17:03





Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.

– Wayne Feltham
Mar 21 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%2f55285234%2fusing-if-statement-to-load-a-list-before-sending-it-via-intent-sending-3-times%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

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현