0

私はapppsで製品を検索する必要があり、別のテーブルでこの製品のいくつかの参照を作成します.toテーブルの両方を作成し、アプリケーションを実行すると、logcatはそれがoncreatの問題であると言います.理解と修正方法を教えてください.それj

ava.lang.RuntimeException: Unable to start activity ComponentInfo{tabet.ventas/tabet.ventas.LigneVente}: java.lang.NullPointerException
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.os.Looper.loop(Looper.java:137)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.app.ActivityThread.main(ActivityThread.java:5039)
05-19 15:20:46.934: E/AndroidRuntime(799):  at java.lang.reflect.Method.invokeNative(Native Method)
05-19 15:20:46.934: E/AndroidRuntime(799):  at java.lang.reflect.Method.invoke(Method.java:511)
05-19 15:20:46.934: E/AndroidRuntime(799):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-19 15:20:46.934: E/AndroidRuntime(799):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-19 15:20:46.934: E/AndroidRuntime(799):  at dalvik.system.NativeStart.main(Native Method)
05-19 15:20:46.934: E/AndroidRuntime(799): Caused by: java.lang.NullPointerException
05-19 15:20:46.934: E/AndroidRuntime(799):  at tabet.ventas.LigneVente.onCreate(LigneVente.java:42)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.app.Activity.performCreate(Activity.java:5104)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-19 15:20:46.934: E/AndroidRuntime(799):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-19 15:20:46.934: E/AndroidRuntime(799):  ... 11 more

そして私の活動のためにLigneVente

   public class LigneVente extends Activity {
    SQLiteDatabase dlv;
    EditText inputNom;
    EditText inputDate;
    EditText txtrechercheProduit;
    EditText nom_produit_vente;
    EditText quantite_stock_vente;
    EditText prix_ligne_vente;
    EditText Qte_voulue;
    String recID="0";
     @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.ligne_vente);

         txtrechercheProduit =(EditText)findViewById(R.id.txtrechercheProduit);  
         nom_produit_vente=(EditText)findViewById(R.id.nom_produit_vente);
         Qte_voulue=(EditText)findViewById(R.id.Qte_voulue);
          prix_ligne_vente=(EditText)findViewById(R.id.prix_ligne_vente);

          txtrechercheProduit.requestFocus(); 
         nom_produit_vente.setEnabled(false);
         quantite_stock_vente.setEnabled(false);
         prix_ligne_vente.setEnabled(false);

      createDB();

      Qte_voulue=(EditText)findViewById(R.id.Qte_voulue);
      Button btn_chercher=(Button)findViewById(R.id.btn_chercher);
      Button btn_valid=(Button)findViewById(R.id.Valider_choix);
      dlv=openOrCreateDatabase("produitbase.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
      btn_chercher.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                if (txtrechercheProduit.getText().toString().equals(""))
                {
                Toast.makeText(LigneVente.this, "Entrer le produit a rechercher.", Toast.LENGTH_SHORT).show();
                }
                else
                {
                searchRecord();
                }
                }
                }); 


      btn_valid.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                if (Qte_voulue.getText().toString().equals(""))
                {
                Toast.makeText(LigneVente.this, "Entrer la Qte a vouloir acheté", Toast.LENGTH_SHORT).show();
                }
                else
                {
                    insert();
                }
                }
                }); 

      inputNom = (EditText) findViewById(R.id.nom);
        inputDate = (EditText) findViewById(R.id.date);
        Button btnenvoifact = (Button) findViewById(R.id.btnEnvoyer);
        btnenvoifact.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                //Starting a new Intent
                Intent verifierFacture = new Intent(getApplicationContext(), FactureActivity.class);

                //envoyer nom du client et la date a la facture 
                verifierFacture.putExtra("nom", inputNom.getText().toString());
                verifierFacture.putExtra("date", inputDate.getText().toString());

                // ouvrire la fenétre facture ou nn ..!!???
                startActivity(verifierFacture);

            }
        }); 

      Button btnretour = (Button) findViewById(R.id.btn_retour);
      btnretour.setOnClickListener(new View.OnClickListener() {

          @Override
          public void onClick(View view) {
              // Launching produit Screen
   //@_@       Intent i = new Intent(getApplicationContext(), VenteBoxClass.class);
     //@_@     startActivity(i);   
          }
      });
      Button btnvalider = (Button) findViewById(R.id.Valider_choix);
      Button btnrecherche = (Button) findViewById(R.id.btn_chercher);

    }
4

1 に答える 1

0
package tabet.ventas;

import java.util.Locale;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LigneVente extends Activity {
    SQLiteDatabase dlv;
    EditText inputNom;
    EditText inputDate;
    EditText txtrechercheProduit;
    EditText nom_produit_vente;
    EditText quantite_stock_vente;
    EditText prix_ligne_vente;
    EditText prix_vente;
    EditText Qte_voulue;
    String recID="0";
     @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.ligne_vente);

         txtrechercheProduit =(EditText)findViewById(R.id.txtrechercheProduit);  
         nom_produit_vente=(EditText)findViewById(R.id.nom_produit_vente);
         quantite_stock_vente=(EditText)findViewById(R.id.quantite_stock_vente);
         prix_ligne_vente=(EditText)findViewById(R.id. prix_ligne_vente);

          txtrechercheProduit.requestFocus(); 
         nom_produit_vente.setEnabled(false);
         quantite_stock_vente.setEnabled(false);
         prix_ligne_vente.setEnabled(false);

      createDB();

      Qte_voulue=(EditText)findViewById(R.id.Qte_voulue);
      Button btn_chercher=(Button)findViewById(R.id.btn_chercher);
      Button btn_valid=(Button)findViewById(R.id.Valider_choix);
      dlv=openOrCreateDatabase("produitbase.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
      btn_chercher.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                if (txtrechercheProduit.getText().toString().equals(""))
                {
                Toast.makeText(LigneVente.this, "Entrer le produit a rechercher.", Toast.LENGTH_SHORT).show();
                }
                else
                {
                searchRecord();
                }
                }
                }); 


      btn_valid.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                if (Qte_voulue.getText().toString().equals(""))
                {
                Toast.makeText(LigneVente.this, "Entrer la Qte a vouloir acheté", Toast.LENGTH_SHORT).show();
                }
                else
                {
                    insert();
                }
                }
                }); 

      inputNom = (EditText) findViewById(R.id.nom);
        inputDate = (EditText) findViewById(R.id.date);
        Button btnenvoifact = (Button) findViewById(R.id.btnEnvoyer);
        btnenvoifact.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                //Starting a new Intent
                Intent verifierFacture = new Intent(getApplicationContext(), FactureActivity.class);

                //envoyer nom du client et la date a la facture 
                verifierFacture.putExtra("nom", inputNom.getText().toString());
                verifierFacture.putExtra("date", inputDate.getText().toString());

                // ouvrire la fenétre facture ou nn ..!!???
                startActivity(verifierFacture);

            }
        }); 

      Button btnretour = (Button) findViewById(R.id.btn_retour);
      btnretour.setOnClickListener(new View.OnClickListener() {

          @Override
          public void onClick(View view) {
              // Launching produit Screen
   //@_@       Intent i = new Intent(getApplicationContext(), VenteBoxClass.class);
     //@_@     startActivity(i);   
          }
      });
      Button btnvalider = (Button) findViewById(R.id.Valider_choix);
      Button btnrecherche = (Button) findViewById(R.id.btn_chercher);

    }
于 2013-05-19T15:33:25.640 に答える