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
| import java.util.Locale;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import data.locdvd.DatabaseFilm;
import data.locdvd.FicheAdapter;
import data.locdvd.FicheBean;
public class Fiche extends Activity {
protected static final String FicheBean = null;
private ScrollView scrollviewFiche;
private FicheAdapter ficheAdapter;
private DatabaseFilm databaseFiche;
private FicheBean fiche;
public void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.fiche);
Log.i("ENI","vu fiche");
scrollviewFiche = (ScrollView)findViewById(R.id.scrollViewFiche);
databaseFiche = new DatabaseFilm (getBaseContext(), "dbFiche.db", null, 1);
SQLiteDatabase db = databaseFiche.getReadableDatabase();
db.setLocale(Locale.FRENCH);
String[] listCol = {"id", "cat", "titre", "realisateur", "img", "id-fiche", "datedesortie", "interdit", "genre", "duree", "resume", "acteurs", "bandeson", "bandeannonce"};
String whereCond = "cat=?";
String[] whereArg = {"policier", "serie", "doc", "Fiction"};
Cursor result = db.query ("tab_fiche", listCol, whereCond, whereArg, null, null, null);
int nbrRec = result.getCount();
Log.i("ENI", "Nbr data= "+ String.valueOf(nbrRec));
if(nbrRec>0){
ficheAdapter = new FicheAdapter(this, R.layout.ficheligne);
result.moveToFirst();
while(!result.isAfterLast()){
FicheBean fiche = new FicheBean();
int id = result.getInt(0);
Log.i("ENI", "ID= "+String.valueOf(id));
String strCat = result.getString(1);
fiche.setStrCat(strCat);
Log.i("ENI", "cat= "+strCat);
String strTitre = result.getString(2);
fiche.setStrTitre(strTitre);
Log.i("ENI", "titre= "+ strTitre);
String strReal = result.getString(3);
fiche.setStrRealisateur(strReal);
Log.i("ENI", "realisateur= "+ strReal);
String strImg = result.getString(4);
Log.i("ENI", "Titre= "+ strImg);
String path= getPackageName() + ":drawable/" + strImg;
int resId = getResources().getIdentifier(path, null, null);
fiche.setiImg(resId);
ficheAdapter.add(fiche);
result.moveToNext();
}
//scrollviewFiche.setAdapter(ficheAdapter); //// ?????? ca se corse à partir d'ici
result.close();
}
scrollviewFiche.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> a, View v, int position, long id){
//on recupere la HashMap contenant les infos de notre item (titre, description, img)
FicheBean fiche = new FicheBean();
fiche=(FicheBean).getItemAtPosition(position);
Intent intent = new Intent (Fiche.this, Fiche.class);
intent.putExtra("titre", fiche.getTitre());
startActivity(intent);
}
});
} |
Partager