Cómo mostrar los elementos RecyclerView después de hacer clic en el botón "Ver todos"

Geetika Sachdeva:

Soy un principiante en el androide. Estoy creando una aplicación en la que se muestran los datos a través recyclerview, pero quiero que sólo algunos artículos deben mostrar en recyclerview.

Sin embargo, cuando el usuario hace clic en el botón "Ver todos", entonces sólo los artículos enteros deben mostrar. ¿Puede alguien decirme cómo puedo hacer esto?

viewtext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getContext(), AppviewActivity.class);
            intent.putExtra("mylist","newmodel");
            getContext().startActivity(intent);
        }
    });

DetailsActivity.java

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_appview);
    ArrayList<String> mylist = (ArrayList<String>) getIntent().getSerializableExtra("mylist");

}

clase newmodel

public class NewModel  {
Drawable sociallogo;
String socailtext;
String href;
public NewModel(Drawable sociallogo, String socailtext, String href){
    this.sociallogo = sociallogo;
    this.socailtext= socailtext;
    this.href = href;

}
public Drawable getSociallogo(){
    return sociallogo;
}
public String getSocailtext(){
    return socailtext;
}
public String getHref(){
    return href;
}

}

o bien:

getItemCount trabajo método para limitación.

Si enlaza con el siguiente código a continuación, muestra los datos limitados.

private final int limit = 10;


 @Override
public int getItemCount() {
    if(arrayList.size() > limit){
        return limit;
    }
}

Al hacer clic en el botón "Ver todos" y luego redirigir a la nueva actividad y de vinculación de datos en el recyclerviewadaptador:

Si enlaza con el siguiente código a continuación, que muestra todos los datos.

@Override
    public int getItemCount() {
        if(arrayList.size() > limit){
            return ad_list.size();
        }
    }

Implementar la clase del modelo, como a continuación código:

public class NewModel implements Serializable {

Ahora pasa sus datos con código de abajo:

viewtext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getContext(), AppviewActivity.class);
            intent.putExtra("mylist", newmodel);
            getContext().startActivity(intent);
        }
    });

Obtener sus datos en la nueva actividad como:

Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
ArrayList<NewModel> mylist = (ArrayList<NewModel>) bundle.getSerializable("mylist");
        }  

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=282519&siteId=1
Recomendado
Clasificación