3

I'm have a recycler view with installers apps, and I'm wanting to pin specific apps at the top, but I want those apps to scroll with the recycler view.

Kind of like how frequently used apps scroll with the app drawer on the stock launcher.

But I have been unable to find any information about this online. Can anyone point me in the right direction?

Here is my current adapter, I am currently using a listview but want to switch over to 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;

}

}

Like the picture, I want apps at the top that are dedicated, and then below all installed apps

Thanks what I'm trying to accomplish

Jenova Projects
  • 119
  • 3
  • 14
  • Are you looking for something like this? https://stackoverflow.com/questions/32949971/how-can-i-make-sticky-headers-in-recyclerview-without-external-lib/43665611#43665611 – tim.paetz Nov 09 '17 at 15:13
  • Not quite,I edited with an image of what I want to do – Jenova Projects Nov 09 '17 at 15:16
  • Correction. Do what washichi said. – tim.paetz Nov 09 '17 at 15:19
  • I don't know how you fill your recyclerview, but If it's a list or something similar, can't you just set the first items in the list to the items you want on top? that way they will scroll with your recyclerview. please post some code of your adapter – washichi Nov 09 '17 at 15:20
  • updated with my current code – Jenova Projects Nov 09 '17 at 15:34
  • 1
    esentially I want to have the recyclerview fill-parent, and on the top of the view I want to have 8 dedicated apps that are always there and the same. and then below that I want the installed apps... but I want it all to scroll together – Jenova Projects Nov 09 '17 at 15:36

0 Answers0