当我点击按钮? edittext中的插入值应为total,并使用SELECT QUERY在另一个edittext中显示Calculate?

时间:2014-07-10 07:35:41

标签: android xml android-edittext

所有插入PaymentPaid(editText)的值应为sum并显示为totalamt(Edittext)。  “

Next.setOnClickListener(new View.OnClickListener(){

    public void onClick(View arg0) {

    try {

                String sql= Select-------?
        String amntpaid=PaymentPaid.getText().toString();       
        String totamnt=totalamt.getText().toString();
                }
                catch (Exception e) {
                e.printStackTrace();
                }
                }
            });`

1 个答案:

答案 0 :(得分:2)

试试这个.......

 int subtotal = 0;
 int total =0;
 Cursor  cursor = dh.rawQuery("SELECT _column_name FROM table_name WHERE _column_name LIKE ? ", new String[] {"%"});
if(cursor.moveToFirst())   
            do{

    subtotal = cursor.getInt(cursor.getColumnIndex("_column_name"));
                total = total+subtotal;
            }while(cursor.moveToNext());
     total_show_edttxt.setext(total);