2
Hello, I’m having a problem, my Toolbar is repeating every time I add a new record.
how do I fix it? follows the codes:
public class ListarReportes extends BaseActivity{
Usuario usuario;
RepositorioReporte repositorioReporte;
RecyclerView recyclerView;
ReportListAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recycler_view);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_listar_reportes);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setCustomView(R.layout.teste);
}
//Recupera sessao do usuario
usuario = (Usuario) getIntent().getSerializableExtra("usuario");
recyclerView = (RecyclerView) findViewById(R.id.rv);
recyclerView.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(this);
recyclerView.setLayoutManager(llm);
recyclerView.setItemAnimator(new DefaultItemAnimator());
repositorioReporte = new RepositorioReporte(this);
List<Reporte> reporte = repositorioReporte.listaQuery(usuario.getId());
adapter = new ReportListAdapter(reporte);
recyclerView.setAdapter(adapter);
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rv"
/>
Are you sure your Toolbar is not within the layout of your registry? By the way, the layout you posted is weird, it starts with a include and ends with Cardview. This doesn’t even compile.
– Androiderson
as well within my record?
– Biellx
This layout you posted is the
R.layout.recycler_view
?– Androiderson
no, I think it’s a bug of the pq stackoverflow I posted the whole layout and it divided into lol parts
– Biellx
Try to edit and place both your Activity layout and your Recycler view layout.
– Androiderson
Try Now @Androiderson
– Biellx
I got it! Thanks to your comment on Recycler view, I realized that Toolbar is for you in the xml of Recycler and not in cardview.
– Biellx
Exactly, I wrote in the answer area to close the question.
– Androiderson