-2

I'm following a tutorial about RecyclerView, but I can't write ct: the way he did. I typed in manually, but it does not work. I'm not sure how he typed it. He typed in this, then android studio writes ct: automatically. What do I need to type to do that?

how to write ct

MyAdapter is a class I created for RecyclerView. Here is the code for that class:

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {

    //Variables
    String game_Name[], game_Description[];
    int img[];
    Context context;

    //Constructor
    public MyAdapter(Context ct, String gameName[], String gameDescription[], int images[]){
        context = ct;
        game_Name = gameName;
        game_Description = gameDescription;
        img = images;
    }

    //Method
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return null;
    }

    //Method
    @Override
    public void onBindViewHolder(@NonNull MyAdapter.MyViewHolder holder, int position) {

    }

    //Method
    @Override
    public int getItemCount() {
        return 0;
    }

    public class MyViewHolder extends RecyclerView.ViewHolder{
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }

}

1 Answer 1

2

The little lighter colored "ct" prompt is just a visual aid and it does not always show up. When you provide a raw value as an argument, it will show the prompt (like this, 1, or "foo"). When you provide a variable for the argument like ctx, foo, etc, it does not show up. This goes for all functions that take arguments.

The moral of the story is, it is not important and can be ignored.

1
  • For better understanding you can type ctrl+p to see the parameters the Adaper would take Commented Jun 15, 2021 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.