我正在将数据从片段传递到其活动容器。现在,当我单击工具栏菜单时,需要存储此数据。我该怎么办?
片段:
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = 1;
ReaderActivity page = (ReaderActivity) getActivity();
page.markPage(String.valueOf(position));
}
});
活动:
public void markPage(String page){
Log.i("INFO", page);
}
onOptionsItemSelected:
if (id == R.id.menu_position) {
firebaseRef.child("markPage")
.child(idUser)
.child("pagePosition")
.setValue("Here I need to move the position");}