samedi 29 août 2015

How show process dialog for get data from Sqlite and show in listview

I want to when the button is clicked, a dialog processor is displayed as long as the list view full list after the jump view the other processor lines to be displayed. please guide me .

this code

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {


         openandquery();
        displayResultList();



        }
    });


public void openandquery() {

     baseHelper= new DataBaseHelper(contex);
     boolean exists=  baseHelper.checkDataBase();


      if (exists){

     message.messages(contex, "True : There database ");

        try {
            boolean open= baseHelper.openDataBase();


                  if (open)
                  {
                  message.messages(contex, "True : database open");

                      Cursor cursor= baseHelper.getTestData(edittext.getText().toString());
                        countf=cursor.getCount();
                      if (countf<=0)message.messages(contex, "Not Found");
                  }

                      else 
                      message.messages(contex, "False : NO database open");
        } catch (SQLException e) {

            message.messages(contex, "Error Open  : " + e.getMessage());

        }   


      }

         else 
                  message.messages(contex, "False : There is no database");

    }





private void displayResultList() {

        try {

        array=baseHelper.results;
        tView.setText("Size : " +array.size());

            try {


                 arrayAdapter=new display();
                arrayAdapter.notifyDataSetChanged();
                listV.setAdapter(arrayAdapter);

            } catch (Exception e) {
             message.messages(contex, e.getMessage());
            }

            listV.setTextFilterEnabled(true);

        } catch (Exception e) {
             message.messages(contex, e.getMessage());
        }



        }

this code called in openandquery

 public Cursor getTestData(String phone)
    { 

        String  sql ="SELECT * FROM cusomer WHERE address!='' and key='"+p;
         message.message(mContext, ":"+p+":");
        try
        {
             if (p.isEmpty())
             {sql="SELECT * FROM cusomer WHERE address!=''";


             }


            Cursor mCur = mDataBase.rawQuery(sql, null);

            message.message(mContext, mCur.getCount()+"");
            if (mCur!=null)
            {

                if (mCur.moveToFirst()){
                              try {

                    do{
                          String d=mCur.getString(mCur.getColumnIndex("address"));
                          String p= mCur.getString(mCur.getColumnIndex("phone")); 
                          int    k=mCur.getInt(mCur.getColumnIndex("key"));
                          int    i=mCur.getInt(mCur.getColumnIndex("_id"));
                          long t=mCur.getLong(mCur.getColumnIndex("registertime"));

                          results.add(new msgstore(d,p,k,i,t));


                      }while(mCur.moveToNext());



                } catch (Exception e) {
                    message.message(mContext, e.getMessage());

                }
                }

           mCur.close();

            }



                return mCur;





        }
        catch (SQLException mSQLException) 
        {
            message.message(mContext, "getTestData >>"+ mSQLException.toString());

            throw mSQLException;
        }






    }

Aucun commentaire:

Enregistrer un commentaire