IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants graphiques Android Discussion :

probléme listview (text filter)


Sujet :

Composants graphiques Android

  1. #1
    Membre à l'essai
    Inscrit en
    Février 2010
    Messages
    19
    Détails du profil
    Informations forums :
    Inscription : Février 2010
    Messages : 19
    Points : 13
    Points
    13
    Par défaut probléme listview (text filter)
    bonjours je veux faire la recherche dans un list view, mais j'ai klk problèmes

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    public class menu extends Activity {
    	private ListView listContent;
    	private EditText et;
    	private ArrayList<String> array_sort= new ArrayList<String>();
    	int textlength=0;
    private SQLiteAdapter mySQLiteAdapter;
     
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.dictionnaire);
     
     
           listContent = (ListView)findViewById(R.id.contentlist);
           et = (EditText) findViewById(R.id.villeRecherche);
     
          /*
           *  Create/Open a SQLite database
           *  and fill with dummy content
           *  and close it
           */
          mySQLiteAdapter = new SQLiteAdapter(this);
          mySQLiteAdapter.openToWrite();
          mySQLiteAdapter.deleteAll();
     
          mySQLiteAdapter.insert("abondante");
          mySQLiteAdapter.insert("abonné");
          mySQLiteAdapter.insert("abonnement");
          mySQLiteAdapter.insert("abonnements");
          mySQLiteAdapter.insert("abonner");
          mySQLiteAdapter.insert("avril");
          mySQLiteAdapter.insert("bagage");
          mySQLiteAdapter.insert("baisse");
          mySQLiteAdapter.insert("baisser");
          mySQLiteAdapter.insert("bancaire");
          mySQLiteAdapter.insert("banque");
          mySQLiteAdapter.insert("barbie");
          mySQLiteAdapter.insert("bas");
          mySQLiteAdapter.insert("bateau");
     
          mySQLiteAdapter.close();
     
          /*
           *  Open the same SQLite database
           *  and read all it's content.
           */
          mySQLiteAdapter = new SQLiteAdapter(this);
          mySQLiteAdapter.openToRead();
     
          Cursor cursor = mySQLiteAdapter.queueAll();
          startManagingCursor(cursor);
     
          String[] from = new String[]{SQLiteAdapter.KEY_CONTENT};
          int[] to = new int[]{R.id.text};
     
          SimpleCursorAdapter cursorAdapter =
           new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
     
          listContent.setAdapter(cursorAdapter);
          et.addTextChangedListener(new TextWatcher()
          {
          public void afterTextChanged(Editable s)
          {
           // Abstract Method of TextWatcher Interface.
          }
          public void beforeTextChanged(CharSequence s,
          int start, int count, int after)
          {
          // Abstract Method of TextWatcher Interface.
          }
          public void onTextChanged(CharSequence s,
          int start, int before, int count)
          {
          textlength = et.getText().length();
          array_sort.clear();
          for (int i = 0; i < from.length; i++)
          {
          if (textlength <= from[i].length())
          {
          if(et.getText().toString().equalsIgnoreCase
        		  ((String)from[i].subSequence(0,textlength)))
          {
          	array_sort.add(from[i]);
                    }
                  }
                            }
          listContent.setAdapter(new ArrayAdapter<String> 
          (menu.this,android.R.layout.simple_expandable_list_item_1, array_sort));
          }
          });
     
     
    listContent.setOnItemClickListener(new OnItemClickListener() {
     
    		public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
    			// TODO Auto-generated method stub
     
    			if (position==0 ) {
    				Intent deus = new Intent(getApplicationContext(), pre.class);
    				startActivity(deus);
    			}
    			if (position==1 ) {
    				Intent deus1 = new Intent(getApplicationContext(), pre.class);
    				startActivity(deus1);
    			}
     
     
    		}
    	});
     
          }
     
    }

  2. #2
    Membre extrêmement actif
    Avatar de Ryu2000
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2008
    Messages
    9 604
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2008
    Messages : 9 604
    Points : 18 520
    Points
    18 520
    Par défaut
    Si toutes les informations sont stocké dans la base de données.
    Tu peux simplement faire une requête qui va te retourner un Cursor et ensuite tu fais
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    adapter.changeCursor();
    .
    Keith Flint 1969 - 2019

  3. #3
    Membre à l'essai
    Inscrit en
    Février 2010
    Messages
    19
    Détails du profil
    Informations forums :
    Inscription : Février 2010
    Messages : 19
    Points : 13
    Points
    13
    Par défaut
    j'ai trouvé une solution

  4. #4
    Membre à l'essai
    Inscrit en
    Février 2010
    Messages
    19
    Détails du profil
    Informations forums :
    Inscription : Février 2010
    Messages : 19
    Points : 13
    Points
    13
    Par défaut
    voice mon code
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. [CSS]problème centrage texte de bouton dans une boîte
    Par Aurelius dans le forum Mise en page CSS
    Réponses: 3
    Dernier message: 06/09/2005, 16h01
  2. [Dreamweaver] problèmes de texte
    Par goma771 dans le forum Dreamweaver
    Réponses: 8
    Dernier message: 12/08/2005, 18h00
  3. [JLabel] Problème de texte tronqué
    Par mister3957 dans le forum Composants
    Réponses: 3
    Dernier message: 06/08/2005, 11h12
  4. [Debutant(e)] Problème fichier texte et vue
    Par solenn dans le forum Eclipse Platform
    Réponses: 2
    Dernier message: 21/07/2004, 09h23
  5. problèmes de textes dynamique dynamiquement générés
    Par stephane eyskens dans le forum Flash
    Réponses: 18
    Dernier message: 05/09/2003, 13h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo