Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将项目固定到回收器视图的顶部_Java_Android_Android Recyclerview - Fatal编程技术网

Java 将项目固定到回收器视图的顶部

Java 将项目固定到回收器视图的顶部,java,android,android-recyclerview,Java,Android,Android Recyclerview,我有一个安装程序应用程序的回收器视图,我想在顶部固定特定的应用程序,但我想让这些应用程序与回收器视图一起滚动 有点像经常使用的应用程序在stock launcher上的应用程序抽屉中滚动 但我一直无法在网上找到任何有关这方面的信息。谁能给我指出正确的方向吗 这是我当前的适配器,我目前正在使用listview,但想切换到recyclerview public class AppListAdapter extends ArrayAdapter<AppModel> { private f

我有一个安装程序应用程序的回收器视图,我想在顶部固定特定的应用程序,但我想让这些应用程序与回收器视图一起滚动

有点像经常使用的应用程序在stock launcher上的应用程序抽屉中滚动

但我一直无法在网上找到任何有关这方面的信息。谁能给我指出正确的方向吗

这是我当前的适配器,我目前正在使用listview,但想切换到recyclerview

public class AppListAdapter extends ArrayAdapter<AppModel> {

private final LayoutInflater mLayoutInflater;

// Simple_list_item_2 contains a TwoLineListItem containing two TextViews.
public AppListAdapter(Context context) {
    super(context, android.R.layout.simple_list_item_2);

    mLayoutInflater = LayoutInflater.from(context);
}

public void setData(ArrayList<AppModel> appsList) {
    clear();
    if (appsList != null) {
        addAll(appsList);
    }
}



//If the platform version supports it add all items in one step, otherwise add in loop
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void addAll(Collection<? extends AppModel> appsCollection) {
    // If internal version of system is higher or equal to lollipop
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        super.addAll(appsCollection);
    }else{
        for(AppModel app: appsCollection){
            super.add(app);
        }
    }
}

/**
 * Put new apps items in the list.
 */
@Override public View getView(int position, View convertView, ViewGroup parent) {
    View view;


    if (convertView == null) {
        view = mLayoutInflater.inflate(R.layout.list_item_icon_text, parent, false);
    } else {
        view = convertView;
    }

    AppModel item = getItem(position);

    if (item.getIcon() == null) {
        Log.d("Icon", " puste");

        return null;
    }
    ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(item.getIcon());


    ((TextView) view.findViewById(R.id.text)).setText(item.getLabel());

    return view;

}

}

公共类AppListAdapter扩展了ArrayAdapter

您正在寻找类似的东西吗?不完全是这样,我编辑了一张我想要纠正的图片。照washichi说的去做。我不知道你是如何填写你的recyclerview的,但是如果它是一个列表或类似的东西,你就不能把列表中的第一个项目设置为你想要在顶部的项目吗?这样,它们将与您的recyclerview一起滚动。请发布你的适配器的一些代码。我想让recyclerview填充父级,在视图顶部,我想有8个始终存在且相同的专用应用程序。下面是我想要安装的应用程序。。。但我希望所有这些都能一起滚动