Android Open Source - SQLite Busquedas






From Project

Back to project page SQLite.

License

The source code is released under:

GNU General Public License

If you think the Android project SQLite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bugsoft.erwin.sqlite1;
/*from  ww w.  j  a va2 s.  c  o  m*/
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.GridView;

import com.bugsoft.erwin.sqlite1.BD.*;

import java.util.ArrayList;

/**
 * Created by erwin on 21/11/14.
 */
public class Busquedas extends Activity implements AdapterView.OnItemClickListener{

    EditText et1;
    GridView gv1;
    ConPers miBase;
    ArrayList<String> miLista;
    ArrayAdapter<String> adaptador;

    Intent ActiPer = new Intent("com.bugsoft.erwin.sqlite1.intent.ActualPer");

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.busquedas);

        et1 = (EditText)findViewById(R.id.editText7);
        gv1 = (GridView)findViewById(R.id.gridView);

        miBase = new ConPers(this);

        miLista = miBase.Obtiene();
        adaptador = new ArrayAdapter<String>(Busquedas.this, android.R.layout.simple_list_item_1, miLista);
        gv1.setAdapter(adaptador);


        et1.setOnKeyListener(new View.OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                miLista.clear();
                miLista = miBase.BusquedaObtiene(et1.getText().toString());
                adaptador = new ArrayAdapter<String>(Busquedas.this, android.R.layout.simple_list_item_1, miLista);
                gv1.setAdapter(adaptador);
                return false;
            }
        });

        gv1.setOnItemClickListener(this);


    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if((position%2)==0){
            if(position!=0){

                String idper = gv1.getItemAtPosition(position).toString();
                Bundle persona = new Bundle();
                persona.putString("id",idper);

                ActiPer.putExtras(persona);
                startActivity(ActiPer);
            }
        }else {
            if(position!=1){

                String idper = gv1.getItemAtPosition(position-1).toString();
                Bundle persona = new Bundle();
                persona.putString("id",idper);

                ActiPer.putExtras(persona);
                startActivity(ActiPer);
            }
        }

    }
}




Java Source Code List

com.bugsoft.erwin.sqlite1.ActualPer.java
com.bugsoft.erwin.sqlite1.ApplicationTest.java
com.bugsoft.erwin.sqlite1.Busquedas.java
com.bugsoft.erwin.sqlite1.MainActivity.java
com.bugsoft.erwin.sqlite1.BD.ConPers.java
com.bugsoft.erwin.sqlite1.BD.PersonaGetSet.java