Show first letter textview

0

I'm getting the data from Firebase and putting it in a ReciclerView. And I'm using the TextDrawable library to display the first letter of the text ScriptName in a circle made the gmail app. I can not get the first letter and show in the circle always comes empty.

public class SecaoViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

public TextView nomeSecao;
ImageView imageView50;


private ItemClickListener itemClickListener;

public void setItemClickListener(ItemClickListener itemClickListener) {
    this.itemClickListener = itemClickListener;
}

public SecaoViewHolder(View itemView) {
    super(itemView);

    nomeSecao = (TextView) itemView.findViewById(R.id.secao_nome);
    imageView50 = (ImageView) itemView.findViewById(R.id.image_view50);


    String primeiraLetra = nomeSecao.getText().toString().substring(0, 1);

        ColorGenerator generator = ColorGenerator.MATERIAL;
        int color = generator.getRandomColor();
        TextDrawable drawable = TextDrawable.builder()
                .buildRound(primeiraLetra, color);


        imageView50.setImageDrawable(drawable);

    itemView.setOnClickListener(this);
}



@Override
public void onClick(View view) {
    itemClickListener.OnClick(view,getAdapterPosition(),false);
}

}

//Carrega o recycleview da Seção com os dados do Firebase
private void loadListSecao(String organizacaoId) {
    adapter = new FirebaseRecyclerAdapter<Secao, SecaoViewHolder>(
            Secao.class,
            R.layout.secao_item,
            SecaoViewHolder.class,
            secaoList.orderByChild("organizacaoId").equalTo(organizacaoId)
    ) {
        @Override
        protected void populateViewHolder(SecaoViewHolder viewHolder, Secao model, int position) {
            viewHolder.nomeSecao.setText(model.getNomeSecao());

            final Secao local = model;

        }
    };

    recyclerView.setAdapter(adapter);
}
    
asked by anonymous 26.03.2018 / 15:34

0 answers