@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (LauncherLog.DEBUG) { LauncherLog.d(TAG, "onCreateView: mEmbedded = " + mEmbedded + ", container = " + container); } findWallpapers(); /* If this fragment is embedded in the layout of this activity, then we should * generate a view to display. Otherwise, a dialog will be created in * onCreateDialog() */ if (mEmbedded) { View view = inflater.inflate(R.layout.wallpaper_chooser, container, false); view.setBackground(mWallpaperDrawable); final Gallery gallery = (Gallery) view.findViewById(R.id.gallery); gallery.setCallbackDuringFling(false); gallery.setOnItemSelectedListener(this); gallery.setAdapter(new ImageAdapter(getActivity())); View setButton = view.findViewById(R.id.set); setButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { selectWallpaper(gallery.getSelectedItemPosition()); } }); return view; } return null; }
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_NO_TITLE); findWallpapers(); setContentView(R.layout.wallpaper_chooser); mGallery = (Gallery) findViewById(R.id.gallery); mGallery.setAdapter(new ImageAdapter(this)); mGallery.setOnItemSelectedListener(this); mGallery.setCallbackDuringFling(false); findViewById(R.id.set).setOnClickListener(this); mImageView = (ImageView) findViewById(R.id.wallpaper); }