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
|
public class SearchActivity extends Activity implements TextWatcher{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_view);
TextView edit = (TextView) findViewById(R.id.editSearch);
edit.addTextChangedListener(this);
}
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
//rechercherMangaNom(s.toString());
String[] types = new String[]{
"Shojo",
"Shonen",
"Seinen",
"Eichi",
"Hentaï"
};
}
public String[] rechercherMangaNom(String nomSaisie) {
CreateDatabase createDatabase = new CreateDatabase(this, Constante.DATABASE_NAME, null, 1);
SQLiteDatabase db = createDatabase.getWritableDatabase();
StringBuffer requeteSql = new StringBuffer();
String[] column = new String[3];
column[0] = "id";
column[1] = "titre";
column[2] = "idType";
requeteSql.append("titre like '%");
requeteSql.append(nomSaisie);
requeteSql.append("%'");
Cursor curs = null;
try{
curs = db.query("titre", column, requeteSql.toString(), null, null, null, "titre ASC");
} catch (Exception e) {
e.printStackTrace();
}
String[] listeNomManga = new String[curs.getCount()];
int compteur = 0;
while (curs.isLast()) {
listeNomManga[compteur] = curs.getString(0);
compteur++;
curs.moveToNext();
}
curs.close();
db.close();
createDatabase.close();
return listeNomManga;
}
} |
Partager