Skip to main content
se eliminó 1 carácter en el cuerpo
Origen Enlace
    public class VerAviso extends AppCompatActivity
{
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    FirebaseUser user = firebaseAuth.getInstance().getCurrentUser();
    List<Aviso> avisos;
    RecyclerView rv;
    Adapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_avisos);

        avisos = new ArrayList<>();
        
        rv=(RecyclerView) findViewById(R.id.rvAvisos);
        rv.setLayoutManager(new LinearLayoutManager(this));
        adapter = new Adapter(eventosavisos);
        rv.setAdapter(adapter);
        
        database.getReference("Aviso").child(user.getUid()).addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                avisos.clear();
                for(DataSnapshot snapshot :
                        dataSnapshot.getChildren()){

                    Aviso aviso2 = snapshot.getValue(Aviso.class);
                    avisos.add(aviso2);

                }
                adapter.notifyDataSetChanged();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
}
    public class VerAviso extends AppCompatActivity
{
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    FirebaseUser user = firebaseAuth.getInstance().getCurrentUser();
    List<Aviso> avisos;
    RecyclerView rv;
    Adapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_avisos);

        avisos = new ArrayList<>();
        
        rv=(RecyclerView) findViewById(R.id.rvAvisos);
        rv.setLayoutManager(new LinearLayoutManager(this));
        adapter = new Adapter(eventos);
        rv.setAdapter(adapter);
        
        database.getReference("Aviso").child(user.getUid()).addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                avisos.clear();
                for(DataSnapshot snapshot :
                        dataSnapshot.getChildren()){

                    Aviso aviso2 = snapshot.getValue(Aviso.class);
                    avisos.add(aviso2);

                }
                adapter.notifyDataSetChanged();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
}
    public class VerAviso extends AppCompatActivity
{
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    FirebaseUser user = firebaseAuth.getInstance().getCurrentUser();
    List<Aviso> avisos;
    RecyclerView rv;
    Adapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_avisos);

        avisos = new ArrayList<>();
        
        rv=(RecyclerView) findViewById(R.id.rvAvisos);
        rv.setLayoutManager(new LinearLayoutManager(this));
        adapter = new Adapter(avisos);
        rv.setAdapter(adapter);
        
        database.getReference("Aviso").child(user.getUid()).addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                avisos.clear();
                for(DataSnapshot snapshot :
                        dataSnapshot.getChildren()){

                    Aviso aviso2 = snapshot.getValue(Aviso.class);
                    avisos.add(aviso2);

                }
                adapter.notifyDataSetChanged();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
}
se añadieron 1466 caracteres en el cuerpo
Origen Enlace
//Tu ya lo tienes peropublic ahoraclass teVerAviso loextends hagoAppCompatActivity
{
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    FirebaseUser user = firebaseAuth.getInstance().getCurrentUser();
    List<Aviso> avisos;
    RecyclerView rv;
    Adapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_avisos);

        avisos = new ArrayList<>();
        
        rv=(RecyclerView) findViewById(R.id.rvAvisos);
        rv.setLayoutManager(new LinearLayoutManager(this));
        adapter = new Adapter(eventos);
        rv.setAdapter(adapter);
        
        database.getReference("Aviso").child(user.getUid()).addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                avisos.clear();
                for(DataSnapshot snapshot :
                        dataSnapshot.getChildren()){

                    Aviso aviso2 = snapshot.getValue(Aviso.class);
                    avisos.add(aviso2);

                }
                adapter.notifyDataSetChanged();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
}
//Tu ya lo tienes pero ahora te lo hago.
    public class VerAviso extends AppCompatActivity
{
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    FirebaseUser user = firebaseAuth.getInstance().getCurrentUser();
    List<Aviso> avisos;
    RecyclerView rv;
    Adapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_avisos);

        avisos = new ArrayList<>();
        
        rv=(RecyclerView) findViewById(R.id.rvAvisos);
        rv.setLayoutManager(new LinearLayoutManager(this));
        adapter = new Adapter(eventos);
        rv.setAdapter(adapter);
        
        database.getReference("Aviso").child(user.getUid()).addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                avisos.clear();
                for(DataSnapshot snapshot :
                        dataSnapshot.getChildren()){

                    Aviso aviso2 = snapshot.getValue(Aviso.class);
                    avisos.add(aviso2);

                }
                adapter.notifyDataSetChanged();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
}
Origen Enlace

Una forma es utilizando RecyclerView

Para hacerlo con RecyclerView necesitas primero hacer 2 xml 1 con El recyclerview el otro con el xml de lo que tendra cada fila

<?xml version="1.0" encoding="utf-8"?>

<android.support.v7.widget.RecyclerView
    android:id="@+id/rvAvisos"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Filas:

<?xml version="1.0" encoding="utf-8"?>

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="100dp">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center">
        <TextView
            android:id="@+id/tvAviso"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="AVISO"
            android:textSize="18dp"
            android:layout_marginBottom="5dp"/>
        <TextView
            android:id="@+id/tvDescripcion"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Descripción"
            android:textSize="14dp"/>
        <TextView
            android:id="@+id/tvUbicacion"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Ubicacion"
            android:textSize="12dp"
            android:layout_gravity="right"
            android:layout_marginEnd="15dp"/>
    </LinearLayout>
</android.support.v7.widget.CardView>

Despues necesitas un Adaptador , el cual recibira la lista de objetos y se encargara de que segun el tamaño de la lista de objetos, pase objeto por objeto poniendo la informacion en cada fila.

public class AdaptadorAvisos extends RecyclerView.Adapter<AdaptadorAvisos.AvisosviewHolder> {
List<Aviso> avisos;



public AdaptadorAvisos(List<Aviso> avisos) {
    this.avisos = avisos;


}

@Override
public AvisosviewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_avisos, parent, false);
    AvisosviewHolder holder = new AvisosviewHolder(v);


    return holder;
}

@Override
public void onBindViewHolder(AvisosviewHolder holder, int position) {
    Aviso aviso = avisos.get(position);
    holder.tvAviso.setText(aviso.get(position).getAvisos);
    holder.tvDescripcion.setText(aviso.get(position).getDescripcion);
    holder.tvUbicacion.setText(aviso.get(position).getUbicacion);

}

@Override
public int getItemCount() {
    return  avisos.size();
}

public static class AvisosviewHolder extends RecyclerView.ViewHolder  {


    TextView tvAviso;
    TextView tvDescripcion;
    TextView tvUbicacion;



    public AvisosviewHolder(View itemView) {
        super(itemView);
        tvAviso = (TextView) itemView.findViewById(R.id.tvAviso);
        tvDescripcion = (TextView ) itemView.findViewById(R.id.tvDescripcion);
        tvUbicacion = (TextView ) itemView.findViewById(R.id.tvUbicacion);


    }


}

}

Por ultimo el Main donde llenas la lista de objetos y mandas la lista al adapter y el adapter lo mandas al RecyclerView

//Tu ya lo tienes pero ahora te lo hago.