Wednesday, April 28, 2010

To Remove Urine Smell From Vinyl

Apply to save the votes in a database with sqlite database

Android Manifest

\u0026lt;? xml version = "1.0" encoding = "utf-8"?>

\u0026lt;manifest xmlns: android = " http://schemas.android.com/apk/res/android" Bottone package = "com.database.tutorial"

android: version code = "1" \u0026lt;activity android: name = "student" & # 160; ; android: label = "@ string / app_name"> Senza titolo ; \u0026lt;intent-filter> ; \u0026lt;action android:name="android.intent.action.MAIN" /> \u0026lt; category android: name = "android.intent.category.LAUNCHER" /> Senza titolo2 \u0026lt; / intent-filter> \u0026lt;/ activity> </manifest>

--------------------------------------------------------------- android ListaVoti

import android.os.Bundle;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;

import android.content.Context;
import android.widget.*; import android.view.View; import android.widget.ListView;
import android.widget.AdapterView;
import android.database.Cursor;
import java.util.ArrayList;
public class ListaVoti extends Activity {
private final String DB_NAME = "Studente.db"
& # 160; private SQLiteDatabase database = null;
private ListView votes
; \u0026lt;String> ArrayList rows = new ArrayList \u0026lt;String> ();
private String LVOT []={" 5 computer 10/02/2010 " "7 Italian 31/01/2010 "," 9 physical education 25/03/2010 "," 7 English 28/02/2010 "};
/ ** Called When the activity is first created. * / @ Override

public void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState)

setContentView (R.layout.listavoti)

creaDatabase ();

; leggiTabellaVoto ();
votes = (ListView) findViewById (R.id.listavoti)
; // By using setAdpater method in listview we an add string array in list.

         voti.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , righe));
    }
    public void creaDatabase(){
         try{          
                    database=openOrCreateDatabase(DB_NAME,SQLiteDatabase.CREATE_IF_NECESSARY, null);
          } catch (SQLiteException e) {
                    System.out.println ("did not create the student database");
e.printStackTrace ();

} ;}
public void leggiTabellaVoto () {
; Cursor c = database.query ("voto", null, null, null , null, null, null, null);
; int numRows = c.getCount();
                    c.moveToFirst();
                    for (int i = 0; i < numrows; + + i) {# &
160; Row r = new Row ();
& # 160; ; r._id = c.getLong(0);
                              r.datav = c.getString(1);
                              r.v = c.getString(2);
                              r.motivo = c.getString(3);
                              r.materia=c.getString(4);
                              r.prof=c.getString(5);
                              String r.v rr = + "" + r.datav + "" + r.materia + "" + r.prof;
, & # 160; ; righe.add (rr);
& # 160; ; c.moveToNext();
                    }
     }
     class Riga {
          public long _id;
          public String v;
public String Datavoice;
public String reason;
& # 160; public String field;
& # 160; public String Professor;
public String name;
& # 160;
} @ Override public void
OnDestroy () {
super.onDestroy ();
; database.close ();}

}

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

Stud Ente

package com.database.tutorial;
import android.app.Activity;
import android.os.Bundle;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.content . Context;
import android.widget .*;
import android.view.View;
import android.content.Intent;
public class Student extends Activity {Ente
; private final String DB_NAME = "Studente.db";   
     private SQLiteDatabase database = null;
      /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
         creaDatabase();
         creaTabellaVoto();
         Button save=(Button)findViewById(R.id.save); Button
list = (Button) findViewById (R.id.listavoti)
& # 160; save.setOnClickListener (onSave)

; lista.setOnClickListener (onLista);}

; private View.OnClickListener View.OnClickListener onSave = new () {

public void onClick (View v) {

edit text datavoto1 = (edit text) findViewById (R.id.datavoto)

edit text voto1 = (text edit) findViewById (R.id.voto)
; motivo1 = edit text (alt text) findViewById (R.id.motivo)
& # 160; materia1 = alt text (alt text) findViewById (R.id.materia)
& # 160; prof1 = edit text (alt text) findViewById (R.id.prof)
& # 160; nome1 = edit text (alt text) findViewById (R.id.nome)
int = Integer.parseInt voto (voto1.getText (). toString ());
& # 160; String datavoto=datavoto1.getText().toString();
               String motivo=motivo1.getText().toString();
               String materia=materia1.getText().toString();
               Prof. prof1.getText String = (). ToString ();
nome1.getText String name = (). toString ();
String insert = "INSERT INTO vote (datavoto , mark, pattern, material, depth, name) values \u200b\u200b('"+
datavoto +"',"+ vote +",'"+ +"','"+ plea on behalf +"','"+ +"','"+ prof + "');";
& # 160; try {
& # 160; database.execSQL (post);
& # 160; System.out.println ("insert done");
} Catch (SQLiteException e) {
& # 160; System.out.println ("entry not occurred");
& # 160; ; e.printStackTrace();
               }
         }
    };
      private View.OnClickListener onLista=new View.OnClickListener(){
         public void onClick(View v) {
            Intent i = new Intent(v.getContext(), ListaVoti.class);
            startActivity(i);
         }
      };          
    public void creaDatabase(){
         try{          
                    database = openOrCreateDatabase (DB_NAME, SQLiteDatabase.CREATE_IF_NECESSARY, null);
} catch (SQLiteException e) {
& # 160; System.out.println ("did not create the database student") ;
e.printStackTrace();
          }
     }
     public void creaTabellaVoto(){
          try{    
                    System.out.println ("I'm here in the table:" + database.toString ());
& # 160; ; if (database.isOpen ()) {
, & # 160; database.execSQL ("CREATE TABLE IF NOT EXISTS votes (_id integer primary key autoincrement, datavoto char (10), vote integer, reason text, subject varchar (50), prof varchar (50), name varchar (50)); ");
& # 160;} &
# 160; } Catch (SQLiteException e) {
& # 160; System.out.println ("did not create the table vote) ;
e.printStackTrace();
          }
     }
     @Override
     public void onDestroy() {
          super.onDestroy();
          Database.close ();}

}



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

listavoti.xml

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

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

\u0026lt;/ linear layout>

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

\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"

>

& # 160; \u0026lt;TableRow>

& # 160; \u0026lt;TextView android:text="I my voti:" />

& # 160; \u0026lt;EditText Android:id="@+id/nome" />

; \u0026lt;/ TableRow>

\u0026lt;TableRow> ;
\u0026lt;TextView Android:text="data:" /> & # 160; \u0026lt;EditText android: id = "@ + id / datavoto" /> \u0026lt; / TableRow>
\u0026lt;TableRow>
& # 160; \u0026lt;TextView android:text="voto:" />
& # 160; \u0026lt;EditText Android:id="@+id/voto" />
; \u0026lt;/ TableRow>
\u0026lt;TableRow> ;
\u0026lt;TextView Android:text="motivo:" />
& # 160; \u0026lt;EditText android: id = "@ + id / motivo" />

\u0026lt; / TableRow>

\u0026lt;TableRow>

& # 160; \u0026lt;TextView android:text="materia:" />

& # 160; \u0026lt;EditText Android:id="@+id/materia" />

; \u0026lt;/ TableRow>

\u0026lt;TableRow> ;
\u0026lt;TextView Android:text="prof:" /> & # 160; \u0026lt;EditText android: id = "@ + id / prof" /> \u0026lt; / TableRow>
\u0026lt;Button android: id = "@ + id / save"
& # 160; android: layout_width = "fill_parent"
& # 160; android: layout_height = "wrap_content"
& # 160; android: text = "Inserisci"
& # 160; />
\u0026lt;Button android: id = "@ + id / listavoti"
& # 160; android: layout_width = "fill_parent"
& # 160; Android: layout_height = "wrap_content"
& # 160; android: text = "View my grades"
, />
\u0026lt;/ TableLayout>

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











0 comments:

Post a Comment