DevGe
DevGe

Reputation: 1449

How to add the static array to the new array list recyclerview using Android java

I have module where I need to list all the data in the recyclerview, I already create this recyclerview on my project however I got error it says that Change 2nd parameter of method player choices from String to String[]. So I already change what the error says. right now still got error incompatible types: String[] cannot be converted to String

Here is the array that I want to list on my recyclerview:

String[] chicken_choice_status = {"Test", "Test2", "Test", "Test2", "Test", "Test2"};

Recyclerview Adapter:

 player_choices[] player_choices = new player_choices[] {
            new player_choices("1",chicken_choice_status,3,4,5)
    };

    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    PlayerChoiceAdapter adapter = new PlayerChoiceAdapter(player_choices);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this.getContext()));
    recyclerView.setAdapter(adapter);

Here is the error:

Error

After updating the class of

private String[] bet_ratio;
String[] bet_ratio
public String[] get_bet_ratio() {
    return bet_ratio;
}
public void setBetRation(String[] bet_ratio) {
    this.bet_ratio = bet_ratio;
}

I'am now getting error of

Error

Hope someone help me for this. Thanks

Upvotes: 0

Views: 332

Answers (2)

Ameya Pandilwar
Ameya Pandilwar

Reputation: 2778

The type of the bet_ratio field should be changed from String to String[] --

String[] bet_ratio;

Upvotes: 0

navylover
navylover

Reputation: 13579

Check the player_choices class to determine the type of the bet_ratio field. It should be defined as:

String[] bet_ratio;

Upvotes: 1

Related Questions