android-developers
[Arriba] [Todas las Listas]

[android-developers] Android Estudio listView Añadir y Búsqueda

To: Android Developers <android-developers@xxxxxxxxxxxxxxxx>
Subject: [android-developers] Android Estudio listView Añadir y Búsqueda
From: Deividas Brazenas <deividas.brazenas@xxxxxxxxx>
Date: Wed, 27 Apr 2016 09:07:32 -0700 (PDT)
Delivery-date: Wed, 27 Apr 2016 12:08:52 -0400
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=sender:date:from:to:message-id:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=PVGu6NghhdCjV8wa5qGDDqpcDkaudZb4tX8zd3gK0P8=; b=v2rAZ6WBIKukZrbB1qklOFEBoosuSFRDOqPGINildoNjzNbZYQhUh2ZZNcwTrTZi09 m62eT7CcI0FQCg27xwzmSBYtCv9h5q1Xg6NXUldFpqM/NViVtK3eSkI0ZYErXgr0tXMd TiJ83LgJ5Ex8tzACXiVMTPyJwIXyR1/SOa0SfiZ6es+/vEgVgddOehEGBoIpOfHO3sNq ptO9v9yPey9OnisZd/Nsm9jyzKClJbMm8YikNYhyPY2HFpfQJKn2XpMZzdGdZAlrjxRp KNS3LPeqBEGUfQip9bG1dFFN+6jVEqHNAAMi4OTitUqbzEdKjkiRxC3LaLzWJtxj7fpp rjWw==
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:message-id:subject:mime-version:x-original-sender :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=PVGu6NghhdCjV8wa5qGDDqpcDkaudZb4tX8zd3gK0P8=; b=fsM2WEEsbIQxWHArpF1byK5dWN4FunK9hXLm6nzJUCkQGzeEk+2xM+X7eCCSx19Ce4 mxDli3rUINvaAwCiC+UFHUOCyv1H8X2+Wl9wCI8D5f0VB/xldHBeoqaQTJsaMRo37v8m akbtsRK7s1DLQxNtaRh5USvbqJojOQcOt7W9hQ+6UPw4US+Bq+aFQRzMlDtsl5X0eMbf ZQkKrbNRanZBEWtxI7u/4/xzo6QiZpOdDoWvw9QI9Q4sYUGn583sh+YJ0U1kArWXERyj JvnW1hV0hiwwE+jlQZJFNtmy+17ca9nt2lluVxdicO6Bl/rq3JVsv+0TE9C1sSqv/Dyf RG2g==
Envelope-to: traductor@xxxxxxxxxxx
List-archive: <https://groups.google.com/group/android-developer>
List-help: <https://groups.google.com/support/>, <mailto:android-developers+help@googlegroups.com>
List-id: <android-developers.googlegroups.com>
List-post: <https://groups.google.com/group/android-developers/post>, <mailto:android-developers@googlegroups.com>
List-subscribe: <https://groups.google.com/group/android-developers/subscribe>, <mailto:android-developers+subscribe@googlegroups.com>
List-unsubscribe: <mailto:googlegroups-manage+364598216046+unsubscribe@googlegroups.com>, <https://groups.google.com/group/android-developers/subscribe>
Mailing-list: list android-developers@xxxxxxxxxxxxxxxx; contact android-developers+owners@xxxxxxxxxxxxxxxx
Reply-to: android-developers@xxxxxxxxxxxxxxxx
Sender: android-developers@xxxxxxxxxxxxxxxx
Tengo una tarea para hacer un *Android aplicación con un `*ListView`, los cuales tienen que 
tener un añadir botón y sistema de búsqueda. He mirado unos cuantos *tutorials ( 
*https://www.youtube.com/reloj?*v=*c9*yC8*XGaSv4 y *https://www.youtube.com/reloj?*v=7*LgEk3*Cg9*Yk 
) y utilizando ambos *tutorials he desarrollado un programa. El programa puede hacer ambas cosas, pero hay un 
*bug. Cuándo yo primero corrido el *app, añado unos cuantos elementos y entonces utilizo la funcionalidad 
de búsqueda. Los trabajos de búsqueda justo bien, pero después de que la búsqueda ha sido 
utilizada una vez, es no más largo laborable. 

Abajo es mi código:


    privado *ArrayList<Cadena> *arrayList;
    privado *ArrayAdapter<adaptador> de Cadena;
    privado *EditText *txtInput;
    *SearchView *searchView;

    protegido *void *onCreate(*Bundle *savedInstanceState)
            #unknown{^*super.*onCreate(*savedInstanceState);
            *setContentView(*R.*layout.La Actividad_principal);
    
            *ListView *listView = (*ListView)*findViewById(*R.*id.*listv);
    
            Elementos de cadena[]={};
    
            *arrayList = nuevo *ArrayList<>(Variedades.*asList(Elementos));
    
            el adaptador = nuevo 
*ArrayAdapter<Cadena>(esto,*android.*R.*layout.Elemento_de lista_sencilla_1,*arrayList);
            *listView.*setAdapter(Adaptador);
    
            *txtInput = (*EditText)*findViewById(*R.*id.*txtinput);
    
            Botón *btAdd = (Botón)*findViewById(*R.*id.*btadd);
    
            *searchView = (*SearchView)*findViewById(*R.*id.*searchView1);
    
            *searchView.*setOnQueryTextListener(Nuevo 
*SearchView.*OnQueryTextListener()
                @#unknown{^*Override
                Público *boolean *onQueryTextSubmit(texto de Cadena)
                    #verbcj falso;
                }
    
                @*Override
                público *boolean *onQueryTextChange(texto de Cadena)
                    #nom.*getFilter().Filtro(texto);
                    el regreso falso;
                }
            });
    
            *btAdd.*setOnClickListener(Vista nueva.*OnClickListener()
                @#unknown{^*Override
                Público *void *onClick(Vista *v)
                    #nom *newItem = *txtInput.*getText().*toString();
                    *arrayList.Añade(*newItem);
                    adaptador.*notifyDataSetChanged();
                }
            });
        }
    }

-- 
Recibiste este mensaje porque eres *subscribed al *Google Grupos "*Android *Developers" grupo.
A *unsubscribe de este grupo y la parón que recibe *emails de él, enviar un *email a *android-*developers+unsubscribe@xxxxxxxxxxxxxxxx.
A correo a este grupo, envía *email a *android-developers@xxxxxxxxxxxxxxxx.
Visita este grupo en *https://grupos.*google.*com/Grupo/*android-*developers.
Para ver esta discusión en la visita de web *https://grupos.*google.*com/*d/*msgid/*android-*developers/*febb9*b5*f-#uno2*ff-4876-9479-0*fe74*b0*bd1*b4%40*googlegroups.*com.
Para más opciones, visita *https://grupos.*google.*com/*d/*optout.
I have a task to make an Android application with a `ListView`, which must 
have an add button and search system. I have watched a few tutorials ( 
https://www.youtube.com/watch?v=c9yC8XGaSv4 and 
https://www.youtube.com/watch?v=7LgEk3Cg9Yk) and using both tutorials I 
have developed a program. The program can do both things, but there is a 
bug. When I first run the app, I add a few items and then I use the search 
functionality. The search works just fine, but after the search has been 
used once, it is no longer working. 

Below is my code:


    private ArrayList<String> arrayList;
    private ArrayAdapter<String> adapter;
    private EditText txtInput;
    SearchView searchView;

    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            ListView listView = (ListView)findViewById(R.id.listv);
    
            String Items[]={};
    
            arrayList = new ArrayList<>(Arrays.asList(Items));
    
            adapter = new 
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,arrayList);
            listView.setAdapter(adapter);
    
            txtInput = (EditText)findViewById(R.id.txtinput);
    
            Button btAdd = (Button)findViewById(R.id.btadd);
    
            searchView = (SearchView)findViewById(R.id.searchView1);
    
            searchView.setOnQueryTextListener(new 
SearchView.OnQueryTextListener() {
                @Override
                public boolean onQueryTextSubmit(String text) {
                    return false;
                }
    
                @Override
                public boolean onQueryTextChange(String text) {
                    adapter.getFilter().filter(text);
                    return false;
                }
            });
    
            btAdd.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    String newItem = txtInput.getText().toString();
                    arrayList.add(newItem);
                    adapter.notifyDataSetChanged();
                }
            });
        }
    }

-- 
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to android-developers@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/febb9b5f-a2ff-4876-9479-0fe74b0bd1b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Anterior por Tema] Tema Actual [Siguiente por Tema>