Skip to content

Instantly share code, notes, and snippets.

@SeongUgJung
Last active March 20, 2016 11:11
Show Gist options
  • Save SeongUgJung/b0d9bd0e33b962ef3796 to your computer and use it in GitHub Desktop.
Save SeongUgJung/b0d9bd0e33b962ef3796 to your computer and use it in GitHub Desktop.
public class MainActivity extends Activity {
@Override public void onCreate(Bundle savedInstance) {
RecyclerView rv = findViewById(R.id.lv);
RecyclerView.Adapter adapter = new SampleAdapter();
rv.setAdapter(adapter);
adapter.add(new Data());
adapter.add(new Data()); // add Data
adapter.nofityDatasetChanged(); // refresh Screen
}
private static class SampleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
List<Data> datas;
SampleAdapter() {
datas = new ArrayLst<Data>();
}
public void add(Data data) {
datas.add(data);
}
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment