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

base de données , scrollview

  1. granola
    granola
    Bonjour,

    Voila g cree une base de donnees et une vue pour afficher une liste de film comportant (une image, un titre, le realisateur ) une fois que l'on selectionne une image je suis censé arriver sur une fiche , jusqu'ici pas de souci , mais etant donné que g plrs film donc g decidé de creer une base de données pour les fiches
    petit detail : ma vue est une scrollview : g suivi pas a pas comme g fé precedemment au moment de faire scrollviewFiche.setAdapter(ficheAdapter); ce dernier ne ne compile pas je ne c pas ce qu'il attend de moi

    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);
    }
    });

    }
Affichage des résultats 1 à 1 sur 1
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