Cant select icons on android device from my SkerlockFragment
<p>I have a main Skerlock fragment that opens when app is run.</p>

<p>Once that is open users can click on an icons sherlock fragment to use tabs to see all the icons i have based on the category they are in.</p>

<p>Now from the app the icons are not able to be selected and applied because my app just showcases them. BUT when a user is on the homescreen and wants to change one of their icons they should be able to select "From File" or "Icon Pack" to use the same sherlock fragment to choose the icon they want to change. </p>

<p>I have this working from an activity fine. The problem is when i converted to a sherlock fragment the icons are not selectable. They show up and i can see they icons on all the tabs but cannot select.</p>

<p>Here is the working activity before i converted to a fragment</p>

<pre><code>public class Icons2 extends Activity implements AdapterView.OnItemClickListener {

public Uri CONTENT_URI;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    int iconSize=getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
    setContentView(R.layout.icon_picker);
    GridView g=(GridView) findViewById(R.id.icon_grid);
    g.setNumColumns(-1);
    g.setColumnWidth(iconSize);
    g.setStretchMode(3);
    g.setVerticalSpacing(iconSize/3);
    g.setOnItemClickListener(this);
    g.setAdapter(new IconsAdapter(this, iconSize));
    g.setOnItemClickListener(this);

    this.CONTENT_URI = Uri.parse("content://" + IconsProvider.class.getCanonicalName());

}
public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long id) {

            String str = adapterView.getItemAtPosition(position).toString();
            setResult(-1, new Intent(null, Uri.withAppendedPath(this.CONTENT_URI, str)));
            finish();
          }

class IconsAdapter extends BaseAdapter{
    private Context mContext;
    private int mIconSize;
    private ArrayList&lt;Integer&gt; mThumbs;

    public IconsAdapter(Context mContext, int iconsize) {
        this.mContext = mContext;
        this.mIconSize = iconsize;
              loadIcons();
            }

    @Override
    public int getCount() {
        return mThumbs.size();
    }

    @Override
    public Object getItem(int position) {
        return mThumbs.get(position);
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(mIconSize, mIconSize));
        } else {
            imageView = (ImageView) convertView;
        }
        imageView.setImageResource(mThumbs.get(position));
        return imageView;
    }

    private void loadIcons() {
        mThumbs = new ArrayList&lt;Integer&gt;();

        final Resources resources = getResources();
        final String packageName = getApplication().getPackageName();

        addIcons(resources, packageName, R.array.icon_pack);
    }
    private void addIcons(Resources resources, String packageName, int list) {
        final String[] extras = resources.getStringArray(list);
        for (String extra : extras) {
            int res = resources.getIdentifier(extra, "drawable", packageName);
            if (res != 0) {
                final int thumbRes = resources.getIdentifier(extra,"drawable", packageName);
                if (thumbRes != 0) {
                    mThumbs.add(thumbRes);
                }
            }
        }
    }

}
</code></pre>

<p>And here is my IconsProvider</p>

<pre><code>public class IconsProvider extends ContentProvider{
@Override
public boolean onCreate() {
    return false;
}

@Override
public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
    return null;
}

@Override
public String getType(Uri uri) {
    return "image/*";
}

@Override
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
    if(uri.getPathSegments().size()&gt;0){
        try{
            int resId=Integer.valueOf(uri.getPathSegments().get(0));
            return this.getContext().getResources().openRawResourceFd(resId);
        }catch (Throwable t){
            return null;
        }
    }else{
        return null;
    }
}

@Override
public Uri insert(Uri uri, ContentValues contentValues) {
    return null;
}

@Override
public int delete(Uri uri, String s, String[] strings) {
    return 0;
}

@Override
public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
    return 0;
}
</code></pre>

<p>And here is what i have for the new fragment version that displays the icons but will not let me pick them</p>

<pre><code>public class Settings extends SherlockFragmentActivity {

private ViewPager mViewPager;
private TabsAdapter mTabsAdapter;

@Override
protected void onCreate(Bundle savedInstanceState2) {
    super.onCreate(savedInstanceState2);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager2);
    setContentView(mViewPager);

    final ActionBar bar = getSupportActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Apps"), IconsAppsFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Games"), IconsGamesFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Folders"), IconsFoldersFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Text"), IconsTextFragment.class, null);
}

public class IconsAppsFragment extends SherlockFragment implements AdapterView.OnItemClickListener {

public Uri CONTENT_URI;

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    int iconSize=getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
    View contentView = inflater.inflate(R.layout.icon_picker, container, false);
    GridView g=(GridView) contentView.findViewById(R.id.icon_grid);
    g.setNumColumns(-1);
    g.setColumnWidth(iconSize);
    g.setStretchMode(3);
    g.setVerticalSpacing(iconSize/3);
    g.setOnItemClickListener(this);
    g.setAdapter(new IconsAdapter(getActivity(), iconSize));
    g.setOnItemClickListener(this);

    this.CONTENT_URI = Uri.parse("content://" + IconsProvider.class.getCanonicalName());
    return contentView;
}
public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long id) {

            String str = adapterView.getItemAtPosition(position).toString();
            getActivity().setResult(-1, new Intent(null, Uri.withAppendedPath(this.CONTENT_URI, str)));
            getActivity().finish();
          }

class IconsAdapter extends BaseAdapter{
    private Context mContext;
    private int mIconSize;
    private ArrayList&lt;Integer&gt; mThumbs;

    public IconsAdapter(Context mContext, int iconsize) {
        this.mContext = mContext;
        this.mIconSize = iconsize;
              loadIcons();
            }

    @Override
    public int getCount() {
        return mThumbs.size();
    }

    @Override
    public Object getItem(int position) {
        return mThumbs.get(position);
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(mIconSize, mIconSize));
        } else {
            imageView = (ImageView) convertView;
        }
        imageView.setImageResource(mThumbs.get(position));
        return imageView;
    }

    private void loadIcons() {
        mThumbs = new ArrayList&lt;Integer&gt;();

        final Resources resources = getResources();
        final String packageName = getSherlockActivity().getPackageName();

        addIcons(resources, packageName, R.array.icon_pack_apps);
    }
    private void addIcons(Resources resources, String packageName, int list) {
        final String[] extras = resources.getStringArray(list);
        for (String extra : extras) {
            int res = resources.getIdentifier(extra, "drawable", packageName);
            if (res != 0) {
                final int thumbRes = resources.getIdentifier(extra,"drawable", packageName);
                if (thumbRes != 0) {
                    mThumbs.add(thumbRes);
                }
            }
        }
    }

}
</code></pre>

<p>I was thinking that i needed an adapter because the sherlockfragment can not use context and that is what is missing.</p>

<p>When i click the icon nothing happens. I need it to select the icons when i user is trying to change their icon on their home screen.</p>

<p>here is that sherlockframentactivity manifest entry</p>

<pre><code>&lt;activity 
            android:label="@string/icons_title" 
            android:name=".Settings" 
            android:icon="@drawable/theme_icon"
            android:noHistory="true"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
            &lt;category android:name="android.intent.category.DEFAULT" /&gt;
            &lt;category android:name="android.intent.category.OPENABLE" /&gt;
            &lt;data android:mimeType="image/*" /&gt;
        &lt;/intent-filter&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.PICK" /&gt;
            &lt;category android:name="android.intent.category.DEFAULT" /&gt;
            &lt;data android:mimeType="image/*" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
    &lt;provider android:name="IconsProvider" android:authorities=".IconsProvider" android:grantUriPermissions="true" /&gt;
</code></pre>
