Émerson Henrique Posted April 26, 2020 at 12:50 AM Report Share #617943 Posted April 26, 2020 at 12:50 AM public class PrincipalActivity extends AppCompatActivity { private RecyclerView recyclerView; private List<MenuVertical> postagens = new ArrayList<>(); @SuppressLint("WrongConstant") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_principal); recyclerView = findViewById(R.id.recyclerView); //Define layout LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayout.VERTICAL); //RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this, 2); recyclerView.setLayoutManager(layoutManager); //Define adapter this.criarListagem(); Adapter adapter = new Adapter(postagens); recyclerView.setAdapter(adapter); } public void criarListagem() { MenuVertical p = new MenuVertical("Émerson Henrique", "Aqui ficam os Textos", R.drawable.miami, "Alguns eu escrevi e outros eu achei que devia colocar"); this.postagens.add(p); p = new MenuVertical("Usuário Henrique", "Aqui ficam algumas músicas", R.drawable.musica, "Musicas Selecionas por mim"); this.postagens.add(p); p = new MenuVertical("Usuário Émerson", "logo em breve vou fazer mais", R.drawable.manutencao, "Em manutenção"); this.postagens.add(p); } } public class Adapter extends RecyclerView.Adapter { private List<MenuVertical> postagens; public Adapter(List<MenuVertical> listaPostagens) { this.postagens = listaPostagens; } @NonNull @Override public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { // tranformar o adapter xml em item view View itemLista = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_lista_vertical, parent, false); return new MyViewHolder(itemLista); } @Override public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { MenuVertical postagem = postagens.get(position); holder.nome.setText(postagem.getNome()); holder.subTitulo.setText(postagem.getSubTitulo()); holder.imagePostagem.setImageResource(postagem.getImagem()); holder.descricao.setText(postagem.getDescricao()); //holder.buttonProx.setOnClickListener((View.OnClickListener) postagem.getButtonProx()); //holder.genero.setText(filme.getGenero()); //holder.ano.setText(filme.getAno()); } @Override public int getItemCount() { return postagens.size(); } public class MyViewHolder extends RecyclerView.ViewHolder { private TextView nome; private TextView subTitulo; private ImageView imagePostagem; private TextView descricao; //Button buttonProx; public MyViewHolder(@NonNull View itemView) { super(itemView); nome = itemView.findViewById(R.id.textNome); subTitulo = itemView.findViewById(R.id.textSubTitulo); imagePostagem = itemView.findViewById(R.id.imagePostagem); descricao = itemView.findViewById(R.id.textDescricao); // buttonProx = itemView.findViewById(R.id.buttonProx); } } } Link to comment Share on other sites More sharing options...
M6 Posted April 27, 2020 at 08:51 AM Report Share #617951 Posted April 27, 2020 at 08:51 AM Tendo em conta o nível do teu post, um titulo e um dump de código, a melhor resposta que poderás obter será algo do género: chegas ao código e metes um id diferente manualmente onde quiseres. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now