Custom ListAdapter showing different data on first row when I add a new item to the DB
<p>I am having a bizarre problem with my custom ListAdapter. I am using this custom ListAdapter, along with overriding bindview() to display a list of payments and penalties from a SQLite Db.</p>

<p>When the user adds a payment, for example $25, it should display as "Payment $25".</p>

<p>When the user adds a penalty, for example $5, they check a "penalty" checkbox and it should display as "Penalty -$5".</p>

<p>To accomplish this, I have a boolean field in a SQLite Db. If penalty is not checked, 0 gets stored in the db. If they do check the penalty checkbox, 1 get stored in the database. This part is working correctly, and I have verified the data itself directly from the db.</p>

<p>Here is my code:</p>

<pre class="lang-java prettyprint-override"><code>TextView pay_pen = (TextView) view.findViewById(R.id.tvPayorPen);

int intIsPen = cursor.getInt(cursor.getColumnIndex(DebtDbAdapter.PAY_ISPENALTY));
Float fltPayAmount = cursor.getFloat(cursor.getColumnIndex(DebtDbAdapter.PAY_AMOUNT));    
String strPayAmount = decim.format(fltPayAmount);

if (intIsPen == 1)
    {
        strPayAmount = "-" + strPayAmount; // add a - if it is a penalty

        pay_pen.setText("Penalty"); // change the word from payment to penalty
    }
</code></pre>

<p>Now that you see how it should work, let me tell you what is happening. I can add a payment, and it will display "Payment: AMOUNT" correctly on the Listview. I can add an unlimited number more payments, still with no issue.</p>

<p>As soon as I add a penalty, however, the first payment in the Listview will display like this: "Penalty $5". It was "Payment $5" before I added the penalty, and now it has changed. The penalty I just added displays (correctly) as a penalty as well.</p>

<p>This is wrong for two reasons. Firstly, the database is showing a 0 for that entry, so boolIsPen should have been 0 and it should have displayed "Payment $5."</p>

<p>Secondly, it is executing the second part of the if code, and that is to change the text to "Penalty" but it is not executing the first half which is to add a "-" in front of the payment/penalty amount.</p>

<p>All the other items in the Listview display correctly, and all the other fields from the Cursor are displaying correctly on the first row. It is just this one field in the first result in the ListView.</p>

<p>Any ideas what I am doing wrong here?</p>
