0
How do I place a recicle view or a list view in some other Ctivity ?
Example: I created a project with name X dai in it so I put the layout as Empty Activity and such it generates me an activity_main layout and a standard Mainactivity class , dai blz if I create other layouts example b Activity and class B , everything I run in class B to show itself in layout B does not appear . What should I do ?
Look at the 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);
}
}
William , thanks for the help looks at the other code .
– Junior
the man code is the main class so I created another Activity with the name start public class extends Appcompatactivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_start); } } then it takes to this code of this screen with name start on it that had to show the recycle , so that from there on the first screen has a button that takes this second , only that on this second screen shows blank does not show the recycle view
– Junior