Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate...Delimiter is showing up in my array values caused by Platform or Emulator
    primarykey
    data
    text
    <p>When I debug the code below it stores the "," (split delimiter) as a value in the array <code>rawData</code>. When <code>parseDouble</code> gets to that value I get a <code>NumberFormatException</code>. Any ideas?</p> <pre><code>package com.simplydesign.android.standarddev; import android.app.Activity; import android.os.Bundle; import android.widget.*; import android.view.*; public class Main extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Button addBtn = (Button) findViewById(R.id.addBtn); final EditText userData = (EditText) findViewById(R.id.editText1); final TextView dataCollection = (TextView) findViewById(R.id.textView1); addBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String[] rawData; rawData = userData.getText().toString().split(","); dataCollection.setText(calculate(rawData)); } }); } public String calculate(String[] a) { double[] convertedData = new double[a.length]; double sum = 0.0; StringBuilder output = new StringBuilder(); int t = 0; for (int f = 0; f&lt;a.length;f++){ convertedData[f] = Double.parseDouble(a[t]); t++; } for (int k = 0; k &lt; convertedData.length; k++) { sum += convertedData[k]; } output.append(sum); return output.toString(); } } </code></pre> <p>After a lot of trial and error I have concluded that my problem was coming from a faulty platform / emulator combination. Originally I had my project platform set to 2.1 with an API value of 7. </p> <p>For whatever reason this was causing problems when I used a comma as a delimiter. It also gave me problems when my numbers had decimal points (the decimal points looked hollow).</p> <p>Now I have my project set to 1.6 and it works with the comma and decimal points. </p> <p>Although I found the solution I still don't understand why this is happening. I feel like some of the apps I create need to be on a high platform, at least 2.5. Is 1.6 ok for most apps? Any suggestions on this matter would be GREATLY appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload