CoverFlow с индивидуальным дизайном в Android

Я разрабатываю одно приложение, в котором я показываю свой собственный дизайн с анимацией обложки, когда я размещаю только изображение, которое отлично работает с образцами... но я пытаюсь работать с моим пользовательским дизайном xml, я терплю неудачу...

изменил

transformImageBitmap (THIS child, Transformation t, int rotateAngle) в

transformImageBitmap (Просмотр дочернего элемента, Transformation t, int rotateAngle)

в CoverFlow.java, но я получаю ClassCastExceptions.

Повторяющийся вопрос Coverflow с пользовательским адаптером

Мой требуемый вывод я нажал здесьвведите здесь описание изображения

public class CoverFlowExample extends Activity {

    ImageAdapter coverImageAdapter;

    /** Called when the activity is first created. */
    @SuppressLint("NewApi")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Use this if you want to use XML layout file
        setContentView(R.layout.main);

        LinearLayout llMain = (LinearLayout) findViewById(R.id.llLayout);

        LinearLayout.LayoutParams layoutParams;

        CoverFlow coverFlow;
        coverFlow = new CoverFlow(this);
        coverFlow.setAdapter(new ImageAdapter(this));
        coverImageAdapter = new ImageAdapter(this);
        coverFlow.setAdapter(coverImageAdapter);
        coverFlow.setSpacing(-50);
        coverFlow.setSelection(8, true);
        layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(0, 20, 0, 0);
        coverFlow.setLayoutParams(layoutParams);
        llMain.addView(coverFlow);

    }

    public class ImageAdapter extends BaseAdapter {
        int mGalleryItemBackground;
        private Context mContext;

        private FileInputStream fis;

        private Integer[] mImageIds = { R.drawable.kasabian_kasabian, R.drawable.starssailor_silence_is_easy,
                R.drawable.killers_day_and_age, R.drawable.garbage_bleed_like_me,
                R.drawable.death_cub_for_cutie_the_photo_album, R.drawable.kasabian_kasabian,
                R.drawable.massive_attack_collected, R.drawable.muse_the_resistance,
                R.drawable.starssailor_silence_is_easy };

        private ImageView[] mImages;

        public ImageAdapter(Context c) {
            mContext = c;
            mImages = new ImageView[mImageIds.length];
        }


        public int getCount() {
            return mImageIds.length;
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {

            LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
            convertView = inflater.inflate(R.layout.sample_item, parent, false);

            LinearLayout llSub = (LinearLayout)convertView.findViewById(R.id.llSub);
            ImageView imageView = (ImageView)convertView.findViewById(R.id.imgDisplay);
            imageView.setImageResource(mImageIds[position]);
            imageView.setLayoutParams(new CoverFlow.LayoutParams(260, 130));
            imageView.setScaleType(ImageView.ScaleType.MATRIX);                         

return imageView;

**Problem facing here**
                //Fail if i retrun my view
                //return convertView;
        }

        /**
         * Returns the size (0.0f to 1.0f) of the views depending on the
         * 'offset' to the center.
         */
        public float getScale(boolean focused, int offset) {
            /* Formula: 1 / (2 ^ offset) */
            return Math.max(0, 1.0f / (float) Math.pow(2, Math.abs(offset)));
        }

    }

}

я получаю исключение в getview, если я возвращаю свое собственное представление дизайна

sample_item.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/llSub"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"
        android:orientation="vertical"
        android:padding="5dip" >

        <ImageView
            android:id="@+id/imgDisplay"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/death_cub_for_cutie_the_photo_album" />
    </LinearLayout>

</LinearLayout>

Мой журнал

06-03 16:34:17.196: E/AndroidRuntime(23511): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.coverflow/com.example.coverflow.CoverFlowExample}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ImageView
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2070)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.app.ActivityThread.access$600(ActivityThread.java:137)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1206)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.os.Looper.loop(Looper.java:213)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.app.ActivityThread.main(ActivityThread.java:4793)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at java.lang.reflect.Method.invokeNative(Native Method)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at java.lang.reflect.Method.invoke(Method.java:511)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at dalvik.system.NativeStart.main(Native Method)
06-03 16:34:17.196: E/AndroidRuntime(23511): Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ImageView
06-03 16:34:17.196: E/AndroidRuntime(23511):    at com.example.coverflow.CoverFlow.makeAndAddView(CoverFlow.java:854)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at com.example.coverflow.CoverFlow.layout(CoverFlow.java:670)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at com.example.coverflow.CoverAbsSpinner.setSelectionInt(CoverAbsSpinner.java:315)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at com.example.coverflow.CoverAbsSpinner.setSelection(CoverAbsSpinner.java:291)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at com.example.coverflow.CoverFlowExample.onCreate(CoverFlowExample.java:51)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.app.Activity.performCreate(Activity.java:5008)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
06-03 16:34:17.196: E/AndroidRuntime(23511):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)

Кто-нибудь может мне помочь

Спасибо в Advance


person NareshRavva    schedule 03.06.2015    source источник
comment
можешь показать свои логи?   -  person Logic    schedule 03.06.2015
comment
Готово, я обновил свой вопрос, можете ли вы его проверить ..   -  person NareshRavva    schedule 03.06.2015
comment
используйте шаблон ViewHoldercodeofaninja.com/2013/09/   -  person Logic    schedule 03.06.2015
comment
я думаю, что проблема не в просмотрщике, мы должны изменить класс CoverFlow.java   -  person NareshRavva    schedule 03.06.2015
comment
coderzheaven.com/2012/12/17 /   -  person NareshRavva    schedule 03.06.2015