Cover flow works in Activity but it gives an error when I convert Activity to Fragment <pre><code> public class AnaSayfa extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { .... ... ... } public View getView(final int position, View convertView, ViewGroup parent) { MyFrame v; if (convertView == null) { v = new MyFrame(AnaSayfa.this); } else { v = (MyFrame)convertView; } v.setImageResource(mResourceIds[position % mResourceIds.length]); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); public static class MyFrame extends FrameLayout { private ImageView mImageView; public void setImageResource(int resId){ mImageView.setImageResource(resId); } public MyFrame(Context context) { super(context); mImageView = new ImageView(context); mImageView.setScaleType(ImageView.ScaleType.FIT_XY); addView(mImageView); setBackgroundColor(Color.WHITE); setSelected(false); } @Override public void setSelected(boolean selected) { super.setSelected(selected); if(selected) { mImageView.setAlpha(1.0f); } else { mImageView.setAlpha(0.5f); } } } </code></pre> <p>I am getting "cannot be applied" error in this code </p> <pre><code>v = new MyFrame(AnaSayfa.this); </code></pre> <p>I used cover flow for the project, but the library is written as an activity, I need to use fragment for Navigation Drawer. I'm new to android.How do i solve this error?.Thanks.</p>