Tuesday, May 11, 2010

Will A Varicose Vein In Labia Go Away

13/05/10 Check Calculator

Calculator saves money occurred in a database

------------------- CalcolatriceDB. Java --- ----------------

package org.me.calcolatricedb;

android.app.Activity import, import clip_image002[4] android.os.Bundle; android.database.sqlite import. SQLiteDatabase; android.widget import .*;

android.view.View import, import

android.content.Intent;

/ **

* * @ author

lollino360

* /
public class CalcolatriceDB extends Activity {
        private final String DB_NAME="Calcolatrice.db";
        private SQLiteDatabase database = null;
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
setContentView (R.layout.main)

; Button sum = (Button) findViewById (R.id.somma)

& # 160; somma.setOnClickListener (somma1)
creaDB () ;
creaTabella ();
Button show = (Button) findViewById (R.id.mostra);
& # 160; mostra.setOnClickListener (onMostra);
/ / ToDo add your GUI initialization code here}

private View.OnClickListener somma1 View.OnClickListener = new () {
public void onClick (View v) {
numero1 = edit text (alt text) findViewById (R.id.num1)
& # 160; numero2 edit text = (text edit) findViewById ( R.id.num2)
& # 160; ris1 = edit text (alt text) findViewById (R.id.ris)
& # 160; int num1 = Integer.parseInt (numero1.getText (). toString ());
& # 160; int num2 = Integer.parseInt (numero2.getText (). toString ());
int res = num1 + num2;
& # 160; String result = num1 num2 +"+"+ +"="+ res;
& # 160; ris1.setText (result);
/ / & # 160; numero1.setText ("");
/ / & # 160; numero2.setText ("");
String insert = "INSERT INTO accounts (operation) values \u200b\u200b('" + result +"');";

& # 160; try {
; database.execSQL (post);
& # 160;} catch (SQLiteException e) {
; e.printStackTrace();
             }

        }
    };
    public void creaDB(){
        try{
            database=openOrCreateDatabase(DB_NAME,SQLiteDatabase.CREATE_IF_NECESSARY,null);

        }catch(SQLiteException e){

            e.printStackTrace();
        }
    }
    public void creaTabella(){
        try{

            if (database.isOpen()){

                         database.execSQL("CREATE TABLE IF NOT EXISTS conti (_id integer primary key autoincrement, operazione varchar(50));");
            }
        }catch(SQLiteException e){
            e.printStackTrace();
        }
    }
     private View.OnClickListener onMostra=new View.OnClickListener(){
         public void onClick(View v) {
            Intent i = new Intent(v.getContext(), Lista.class);
            startActivity(i);
         }
      };

}

-------------------Lista.java-------------------

package org.me.calcolatricedb;

import android.app.Activity;
import android.os.Bundle;
import android.database.sqlite.SQLiteDatabase;
android.database.sqlite.SQLiteException import, import
android.content.Context;

android.widget import .*;

import android.view.View;

android.widget.ListView import, import

android.widget.AdapterView;

import android.database.Cursor;

import java.util.ArrayList;

android.util.Log import, import

android.content.Intent;
public class List extends Activity {
& # 160; private final String DB_NAME = "Calcolatrice.db;
private SQLiteDatabase database = null;
private ListView votes
\u0026lt;String> ArrayList rows = new ArrayList \u0026lt;String> ( )
/ ** Called When the activity is first created. * / @ Override

public void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState)
setContentView (R.layout.lista)
creaDatabase ();
& # 160; leggiTabellaVoto ();
& # 160; votes = (ListView) findViewById (R.id.listav)
/ / By using setAdpater method in listview we add string into an array list.
/ / log. ("votes =" + rating);
voti.setAdapter (new ArrayAdapter \u0026lt;String> (this, android.R.layout. simple_list_item_1, rows));
Button enter = (Button) findViewById (R.id.btnGetMoreResults)
post. setOnClickListener (onInserisci);}

creaDatabase public void () {
; try {
& # 160; database = openOrCreateDatabase (DB_NAME, SQLiteDatabase.CREATE_IF_NECESSARY, null);
} catch (SQLiteException e) {
& # 160; System.out.println ("did not create the database student") ;
e.printStackTrace ();}

& # 160;} public void
leggiTabellaVoto () {

& # 160; ; Cursor c = database.query ("contingent", null, null, null, null, null, null, null);
& # 160; int numRows = c.getCount ();
& # 160; ; c.moveToFirst ();
& # 160; for (int i = 0; i < numRows; ++i) {
                              Riga r = new Riga();
                              r._id = c.getLong(0);
                              r.operazione = c.getString(1);
                              System.out.println(r.operazione);
                              righe.add(r.operazione);
                              c.moveToNext();
                    }

     }

     class Riga {
          public long _id;
          public String operazione;
     }
     private View.OnClickListener onInserisci=new View.OnClickListener(){
         public void onClick(View v) {
            Intent i = new Intent(v.getContext(), CalcolatriceDB.class);
            startActivity(i);
         }

      };

     @Override

     public void onDestroy() {

          super.onDestroy();
          Database.close ();}

}

------------------- main xml. -------------------

\u0026lt;xml version = "1.0" encoding = "UTF-8"?>
\u0026lt;table layout xmlns: android = "
http://schemas.android.com/apk/res/android"

android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: stretch columns = "1"
> ;
\u0026lt;TableRow>

\u0026lt;TextView android: text = "numero"

, & # 160; android: layout_width = "100px"

& # 160; />

\u0026lt;
EditText android: layout_width = "200px" android : layout_height = "wrap_content" & # 160; android: id = "@ + id/num1"
/>
\u0026lt;/ TableRow>
\u0026lt;TableRow> ;
\u0026lt;TextView android: text = "numero"
& # 160; android: layout_width = "100px"
& # 160; />
\u0026lt;EditText
; android: layout_width = "200px"
android: layout_height = "wrap_content"
android: id = "@ + id/num2"
/>
\u0026lt;/ TableRow>
\u0026lt;TableRow>
\u0026lt;TextView android: text = "risultato:"
& # 160; android: layout_width = "100px"
, /> &
# 160; \u0026lt;EditText
android: layout_width = "200px"
android: layout_height = "wrap_content"
& # 160; android: id = "@ + id / ris
/>
\u0026lt;/ TableRow>
\u0026lt;Button android: id = "@ + id / somma"
& # 160; ; android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
& # 160; android: text = "+" &
# 160; />
\u0026lt;Button android: id = "@ + id / mostra"
& # 160; android: layout_width = "fill_parent"
& # 160; android: layout_height = "wrap_content"
; android: text = "Show operations performed"
/>
\u0026lt;/ TableLayout>

------------------- list.
xml -------------------
\u0026lt;? xml version = "1.0" encoding = "UTF-8"?>
\u0026lt;RelativeLayout xmlns: android = "
http://schemas.android.com/apk/res/android"

android: orientation = "horizontal"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
;>

\u0026lt;ScrollView

& # 160; android: layout_height = "fill_parent"

& # 160; android: layout_width = "fill_parent>


\u0026lt;LinearLayout & # 160; android: orientation = "vertical" android : layout_width = "fill_parent" ;
android: layout_height = "fill_parent"
>
& # 160; \u0026lt;ListView android: id = "@ + id / listav"
android: layout_width = "fill_parent"

& # 160; android: layout_height = "300sp"

android: drawSelectorOnTop = " ; false
android: cacheColorHint = "# ff6a00"
android: divider = "ff8f40"

android: dividerHeight = "2px"

& # 160; />
; \u0026lt;relative layout
android: layout_width = " ; fill_parent "
android: layout_height = "fill_parent"
& # 160; android: background = "676 767"
& # 160; android: orientation = "vertical">

; \u0026lt;Button android
: layout_width = "fill_parent"
; android: layout_height = "fill_parent"
android: id = "@ + id / btnGetMoreResults"
android: padding = " ; 10px "android
: text = "Enter new data" />
\u0026lt;/ RelativeLayout>
\u0026lt;Relative layout
android: layout_width = "fill_parent"
& # 160; android: layout_height = "fill_parent"
& # 160; android: background = "676 767"

& # 160; android: orientation = "vertical">


\u0026lt;Button
& # 160; android: layout_width = "fill_parent"
; android: layout_height = "fill_parent"
android: id = "@ + id / btnGetMoreResults1 "
& # 160; android: visibility = "gone"
, android: padding = "10px"
android: text = " ; Shows detagli "/>
\u0026lt;/ RelativeLayout>

\u0026lt;/ LinearLayout>
\u0026lt;/ ScrollView>

\u0026lt;/ RelativeLayout>

----------------------------- ----------------------------





0 comments:

Post a Comment