2

重複の可能性:
AndroidでViewFlipperを使用してsqliteのコンテンツを表示する方法

私はsqliteからデータを取得していますが、ハッシュマップを使用しているため、viewflipperを使用してsqliteのレコードごとにデータを1つずつ表示したいと思います..より明確にするために、sqliteに2つのレコードがあります私が使用しているものを反転して、最初のレコードとそれ以降の2つのレコードを表示します

    cache = new ArrayList<String>();
    while (cursor.moveToNext())
    {

         String temp_bookid = cursor.getString(0);
         Log.i("temp_bookid",temp_bookid);
         String temp_desc=cursor.getString(1);
         byte[] temp_image1 = cursor.getBlob(2);
         byte[] temp_image2 = cursor.getBlob(3);
         String temp_id=cursor.getString(4);
         String temp_name = cursor.getString(5);
         String temp_bname=cursor.getString(6);
         cache.add(temp_id);
         cache.add(temp_bname);
         cache.add(temp_bookid);
         cache.add(temp_name);
         cache.add(temp_desc);
         cache.add(temp_image1.toString());
         cache.add(temp_image2.toString());
            Log.i("temp_id of the page in sqlite", temp_id);

            TextView txtDesc = (TextView) findViewById(R.id.tDescription);
            text = (TextView) findViewById(R.id.tTitle);
            text.setText(temp_name);

            txtDesc.setText(temp_desc);

            ImageView img = (ImageView)findViewById(R.id.smallImage);


            img.setImageBitmap(BitmapFactory.decodeByteArray(temp_image1, 0,temp_image1.length));
            txtName1 = (TextView) findViewById(R.id.tvName);
            txtName1.setText(temp_bname);

            break;
    }   

        mContext = this;
        vf = (ViewFlipper) this.findViewById(R.id.vfShow);
        vf.setOnTouchListener(new OnTouchListener() {
        @Override
            public boolean onTouch(final View view, final MotionEvent event) {
                detector.onTouchEvent(event);
                Log.i("ew","ae");

                return true;
            }
        });

上記のコードを使用すると、breakを使用しているため、最初のレコードデータのみを設定できます。ブレークを削除した場合のステートメント。最後のレコードを表示しています。

誰かが私にviewflipperのsqliteまたは参照するためのあらゆる種類のチュートリアルでデータを設定するための最良のアプローチを提案できますか?

4

0 に答える 0