I'm getting string id
instead of string value in recyclerview
.
Below is my code, I don't know where i'm getting it wrong.
public class Albert_Einstein_Fragment extends Fragment {
private String b;
String[] dataArray ={String.valueOf(R.array.albert_array)};
//...
private class QuoteAdapter extends RecyclerView.Adapter<QuoteHolder>{
private String[] dataSource;
public QuoteAdapter(String[] dataArgs){
dataSource = dataArgs;
}
@Override
public QuoteHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
View view = layoutInflater
.inflate(R.layout.list_quotes, parent, false);
return new QuoteHolder(view);
}
@Override
public void onBindViewHolder(QuoteHolder holder, int position) {
holder.mTaskNameTextView.setText(dataSource[position]);
}
@Override
public int getItemCount() {
return dataSource.length;
}
}
}
}
Below is part of my array string resource code...
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="albert_array">
<item>Let every man be respected as an individual and no man idolized. </item>
<item>God does not play dice. </item>
<item>Great spirits have always encountered violent opposition from mediocre minds.</item>
<item>Only a life lived for others is a life worthwhile.</item>
<item>We shall require a substantially new manner of thinking if mankind is to survive.</item>
<item>I used to go away for weeks in a state of confusion.</item>
</string-array>
</resources>
Below is the output of my code
2131427328
Instead of list of strings in my array string resource