How do I put a recycle view or a list view into some other activity?
Example: I created a project with name X in it as soon as I put the layout as Empty activity and so it generates an activity_main layout and a standard MainActivity class, dai blz if I create other example layouts b activity and class B, everything that squeezes into class B so that it shows in layout B does not appear. What should I do?
Look at main:
public class MainActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private MyAdapter adapter;
private List<RecyclerItem> listItems;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
listItems = new ArrayList<>();
//Generate sample data
for (int i = 0; i<10; i++) {
listItems.add(new RecyclerItem("Item " + (i + 1), "teste " + (i+1)));
}
//Set adapter
adapter = new MyAdapter(listItems, this);
recyclerView.setAdapter(adapter);
}
}