GridView项目的片段?

时间:2017-08-03 02:23:02

标签: android

是否可以在GridView中使用Fragments?

我试过这样做:

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

    if(convertView == null)
    {
        Rune rune = (Rune) getItem(position);
        RuneFragment runeFragment = new RuneFragment();
        FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
        transaction.add(parent.getId(), runeFragment);
        transaction.commit();
        runeFragment.renderRune(rune);

        convertView = parent.findViewById(R.id.rune_grid_fragment);

        Log.i(MainActivity.TAG, "" + convertView); //====> null
    }

    return convertView;
}

但结果是convertView始终为null。

1 个答案:

答案 0 :(得分:0)

你可以这样做。

SELECT * FROM jobs WHERE jobno < 2016000