Want to Update the existing listView in fragment by clicking menuitems
I am creating an app for finding nearby blood donors. In this app I am using three fragments for swipe navigation. Inn one fragment, the available donor list is shown, but I want to change the list from a menu list by on a clicking particular blood group The 1st list is but when I click the items it shows nothing.
Java code:
public class DonorsFragment extends Fragment {
SwipeMenuListView listView;
FirebaseListAdapter adapter;
TextView fullName,bloodGroup,gender,age,address;
Query query;
View rootView;
FirebaseListOptions<DonorAdapterClass> options;
public DonorsFragment() {
// Required empty public constructor
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView =inflater.inflate(R.layout.fragment_donors, container, false);
listView = rootView.findViewById(R.id.listview);
Toast.makeText(getActivity(),"oncreateview",Toast.LENGTH_SHORT).show();
query =FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
SwipeMenuCreator creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(getActivity());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
0x3F, 0x25)));
// set item width
deleteItem.setWidth(170);
// set a icon
deleteItem.setIcon(R.drawable.ic_phone);
// add to menu
menu.addMenuItem(deleteItem);
}
};
listView.setMenuCreator(creator);
listView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
switch (index) {
case 0:
// open
Toast.makeText(getActivity(),"Item Clicked",Toast.LENGTH_SHORT).show();
break;
}
// false : close the menu; true : not close the menu
return false;
}
});
// Inflate the layout for this fragment
return rootView;
}
@Override
public void onStart() {
super.onStart();
adapter.startListening();
}
@Override
public void onStop() {
super.onStop();
adapter.stopListening();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.blood_group_menu,menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.a_pos: {
Toast.makeText(getActivity(),"A+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.a_neg: {
Toast.makeText(getActivity(),"A-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.b_pos: {
Toast.makeText(getActivity(),"B+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_B_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.b_neg: {
Toast.makeText(getActivity(),"B-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_B_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.ab_pos: {
Toast.makeText(getActivity(),"AB+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.ab_neg: {
Toast.makeText(getActivity(),"AB-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
break;
}
case R.id.o_pos: {
Toast.makeText(getActivity(),"O+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_O_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.o_neg: {
Toast.makeText(getActivity(),"O-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_O_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.list_all: {
Toast.makeText(getActivity(),"All",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
break;
}
}
return super.onOptionsItemSelected(item);
}
public void setQuery(Query query){
listView = rootView.findViewById(R.id.listview);
options = new FirebaseListOptions.Builder<DonorAdapterClass>()
.setLayout(R.layout.donor_list)
.setQuery(query,DonorAdapterClass.class)
.build();
adapter = new FirebaseListAdapter(options) {
@Override
protected void populateView(@NonNull View v, @NonNull Object model, int position) {
DonorAdapterClass donors = (DonorAdapterClass) model;
if(donors.getIsDonor().toString().equals("yes")){
fullName = v.findViewById(R.id.fullName_list);
bloodGroup = v.findViewById(R.id.bloodGroup_list);
gender = v.findViewById(R.id.gender_lis);
address = v.findViewById(R.id.address_list);
age = v.findViewById(R.id.age_list);
fullName.setText(donors.getFullName().toString());
bloodGroup.setText(donors.getBloodGroup().toString());
gender.setText(donors.getGender().toString());
address.setText(donors.getAddress().toString());
age.setText(donors.getAge().toString());
}
}
};
listView.setAdapter(adapter);
}
}
all firebase query and adapter is set in setQuery() method..when it is called from onCreateView() it is working...but when it is called from switch case in onOptionsItemSelected it shows nothing and previous list view also hides
Thanks in Advance :)
java android android-fragments firebase-realtime-database android-listview
add a comment |
I am creating an app for finding nearby blood donors. In this app I am using three fragments for swipe navigation. Inn one fragment, the available donor list is shown, but I want to change the list from a menu list by on a clicking particular blood group The 1st list is but when I click the items it shows nothing.
Java code:
public class DonorsFragment extends Fragment {
SwipeMenuListView listView;
FirebaseListAdapter adapter;
TextView fullName,bloodGroup,gender,age,address;
Query query;
View rootView;
FirebaseListOptions<DonorAdapterClass> options;
public DonorsFragment() {
// Required empty public constructor
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView =inflater.inflate(R.layout.fragment_donors, container, false);
listView = rootView.findViewById(R.id.listview);
Toast.makeText(getActivity(),"oncreateview",Toast.LENGTH_SHORT).show();
query =FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
SwipeMenuCreator creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(getActivity());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
0x3F, 0x25)));
// set item width
deleteItem.setWidth(170);
// set a icon
deleteItem.setIcon(R.drawable.ic_phone);
// add to menu
menu.addMenuItem(deleteItem);
}
};
listView.setMenuCreator(creator);
listView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
switch (index) {
case 0:
// open
Toast.makeText(getActivity(),"Item Clicked",Toast.LENGTH_SHORT).show();
break;
}
// false : close the menu; true : not close the menu
return false;
}
});
// Inflate the layout for this fragment
return rootView;
}
@Override
public void onStart() {
super.onStart();
adapter.startListening();
}
@Override
public void onStop() {
super.onStop();
adapter.stopListening();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.blood_group_menu,menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.a_pos: {
Toast.makeText(getActivity(),"A+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.a_neg: {
Toast.makeText(getActivity(),"A-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.b_pos: {
Toast.makeText(getActivity(),"B+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_B_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.b_neg: {
Toast.makeText(getActivity(),"B-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_B_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.ab_pos: {
Toast.makeText(getActivity(),"AB+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.ab_neg: {
Toast.makeText(getActivity(),"AB-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
break;
}
case R.id.o_pos: {
Toast.makeText(getActivity(),"O+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_O_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.o_neg: {
Toast.makeText(getActivity(),"O-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_O_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.list_all: {
Toast.makeText(getActivity(),"All",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
break;
}
}
return super.onOptionsItemSelected(item);
}
public void setQuery(Query query){
listView = rootView.findViewById(R.id.listview);
options = new FirebaseListOptions.Builder<DonorAdapterClass>()
.setLayout(R.layout.donor_list)
.setQuery(query,DonorAdapterClass.class)
.build();
adapter = new FirebaseListAdapter(options) {
@Override
protected void populateView(@NonNull View v, @NonNull Object model, int position) {
DonorAdapterClass donors = (DonorAdapterClass) model;
if(donors.getIsDonor().toString().equals("yes")){
fullName = v.findViewById(R.id.fullName_list);
bloodGroup = v.findViewById(R.id.bloodGroup_list);
gender = v.findViewById(R.id.gender_lis);
address = v.findViewById(R.id.address_list);
age = v.findViewById(R.id.age_list);
fullName.setText(donors.getFullName().toString());
bloodGroup.setText(donors.getBloodGroup().toString());
gender.setText(donors.getGender().toString());
address.setText(donors.getAddress().toString());
age.setText(donors.getAge().toString());
}
}
};
listView.setAdapter(adapter);
}
}
all firebase query and adapter is set in setQuery() method..when it is called from onCreateView() it is working...but when it is called from switch case in onOptionsItemSelected it shows nothing and previous list view also hides
Thanks in Advance :)
java android android-fragments firebase-realtime-database android-listview
IsonOptionsItemSelected()
being called?
– parekhkruti26
Nov 23 '18 at 4:19
Yes..i put toast on it
– Bishal Imtiaz
Nov 23 '18 at 11:16
i forgot to put adapter.stopListening() in setQuery()
– Bishal Imtiaz
Nov 23 '18 at 13:42
add a comment |
I am creating an app for finding nearby blood donors. In this app I am using three fragments for swipe navigation. Inn one fragment, the available donor list is shown, but I want to change the list from a menu list by on a clicking particular blood group The 1st list is but when I click the items it shows nothing.
Java code:
public class DonorsFragment extends Fragment {
SwipeMenuListView listView;
FirebaseListAdapter adapter;
TextView fullName,bloodGroup,gender,age,address;
Query query;
View rootView;
FirebaseListOptions<DonorAdapterClass> options;
public DonorsFragment() {
// Required empty public constructor
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView =inflater.inflate(R.layout.fragment_donors, container, false);
listView = rootView.findViewById(R.id.listview);
Toast.makeText(getActivity(),"oncreateview",Toast.LENGTH_SHORT).show();
query =FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
SwipeMenuCreator creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(getActivity());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
0x3F, 0x25)));
// set item width
deleteItem.setWidth(170);
// set a icon
deleteItem.setIcon(R.drawable.ic_phone);
// add to menu
menu.addMenuItem(deleteItem);
}
};
listView.setMenuCreator(creator);
listView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
switch (index) {
case 0:
// open
Toast.makeText(getActivity(),"Item Clicked",Toast.LENGTH_SHORT).show();
break;
}
// false : close the menu; true : not close the menu
return false;
}
});
// Inflate the layout for this fragment
return rootView;
}
@Override
public void onStart() {
super.onStart();
adapter.startListening();
}
@Override
public void onStop() {
super.onStop();
adapter.stopListening();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.blood_group_menu,menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.a_pos: {
Toast.makeText(getActivity(),"A+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.a_neg: {
Toast.makeText(getActivity(),"A-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.b_pos: {
Toast.makeText(getActivity(),"B+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_B_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.b_neg: {
Toast.makeText(getActivity(),"B-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_B_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.ab_pos: {
Toast.makeText(getActivity(),"AB+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.ab_neg: {
Toast.makeText(getActivity(),"AB-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
break;
}
case R.id.o_pos: {
Toast.makeText(getActivity(),"O+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_O_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.o_neg: {
Toast.makeText(getActivity(),"O-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_O_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.list_all: {
Toast.makeText(getActivity(),"All",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
break;
}
}
return super.onOptionsItemSelected(item);
}
public void setQuery(Query query){
listView = rootView.findViewById(R.id.listview);
options = new FirebaseListOptions.Builder<DonorAdapterClass>()
.setLayout(R.layout.donor_list)
.setQuery(query,DonorAdapterClass.class)
.build();
adapter = new FirebaseListAdapter(options) {
@Override
protected void populateView(@NonNull View v, @NonNull Object model, int position) {
DonorAdapterClass donors = (DonorAdapterClass) model;
if(donors.getIsDonor().toString().equals("yes")){
fullName = v.findViewById(R.id.fullName_list);
bloodGroup = v.findViewById(R.id.bloodGroup_list);
gender = v.findViewById(R.id.gender_lis);
address = v.findViewById(R.id.address_list);
age = v.findViewById(R.id.age_list);
fullName.setText(donors.getFullName().toString());
bloodGroup.setText(donors.getBloodGroup().toString());
gender.setText(donors.getGender().toString());
address.setText(donors.getAddress().toString());
age.setText(donors.getAge().toString());
}
}
};
listView.setAdapter(adapter);
}
}
all firebase query and adapter is set in setQuery() method..when it is called from onCreateView() it is working...but when it is called from switch case in onOptionsItemSelected it shows nothing and previous list view also hides
Thanks in Advance :)
java android android-fragments firebase-realtime-database android-listview
I am creating an app for finding nearby blood donors. In this app I am using three fragments for swipe navigation. Inn one fragment, the available donor list is shown, but I want to change the list from a menu list by on a clicking particular blood group The 1st list is but when I click the items it shows nothing.
Java code:
public class DonorsFragment extends Fragment {
SwipeMenuListView listView;
FirebaseListAdapter adapter;
TextView fullName,bloodGroup,gender,age,address;
Query query;
View rootView;
FirebaseListOptions<DonorAdapterClass> options;
public DonorsFragment() {
// Required empty public constructor
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView =inflater.inflate(R.layout.fragment_donors, container, false);
listView = rootView.findViewById(R.id.listview);
Toast.makeText(getActivity(),"oncreateview",Toast.LENGTH_SHORT).show();
query =FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
SwipeMenuCreator creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(getActivity());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
0x3F, 0x25)));
// set item width
deleteItem.setWidth(170);
// set a icon
deleteItem.setIcon(R.drawable.ic_phone);
// add to menu
menu.addMenuItem(deleteItem);
}
};
listView.setMenuCreator(creator);
listView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
switch (index) {
case 0:
// open
Toast.makeText(getActivity(),"Item Clicked",Toast.LENGTH_SHORT).show();
break;
}
// false : close the menu; true : not close the menu
return false;
}
});
// Inflate the layout for this fragment
return rootView;
}
@Override
public void onStart() {
super.onStart();
adapter.startListening();
}
@Override
public void onStop() {
super.onStop();
adapter.stopListening();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.blood_group_menu,menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.a_pos: {
Toast.makeText(getActivity(),"A+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.a_neg: {
Toast.makeText(getActivity(),"A-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.b_pos: {
Toast.makeText(getActivity(),"B+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_B_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.b_neg: {
Toast.makeText(getActivity(),"B-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_B_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.ab_pos: {
Toast.makeText(getActivity(),"AB+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_A_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.ab_neg: {
Toast.makeText(getActivity(),"AB-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
break;
}
case R.id.o_pos: {
Toast.makeText(getActivity(),"O+",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_O_Pos").equalTo("yes");
setQuery(query);
break;
}
case R.id.o_neg: {
Toast.makeText(getActivity(),"O-",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users").orderByChild("canGive_O_Neg").equalTo("yes");
setQuery(query);
break;
}
case R.id.list_all: {
Toast.makeText(getActivity(),"All",Toast.LENGTH_SHORT).show();
query=FirebaseDatabase.getInstance().getReference().child("Users");
setQuery(query);
break;
}
}
return super.onOptionsItemSelected(item);
}
public void setQuery(Query query){
listView = rootView.findViewById(R.id.listview);
options = new FirebaseListOptions.Builder<DonorAdapterClass>()
.setLayout(R.layout.donor_list)
.setQuery(query,DonorAdapterClass.class)
.build();
adapter = new FirebaseListAdapter(options) {
@Override
protected void populateView(@NonNull View v, @NonNull Object model, int position) {
DonorAdapterClass donors = (DonorAdapterClass) model;
if(donors.getIsDonor().toString().equals("yes")){
fullName = v.findViewById(R.id.fullName_list);
bloodGroup = v.findViewById(R.id.bloodGroup_list);
gender = v.findViewById(R.id.gender_lis);
address = v.findViewById(R.id.address_list);
age = v.findViewById(R.id.age_list);
fullName.setText(donors.getFullName().toString());
bloodGroup.setText(donors.getBloodGroup().toString());
gender.setText(donors.getGender().toString());
address.setText(donors.getAddress().toString());
age.setText(donors.getAge().toString());
}
}
};
listView.setAdapter(adapter);
}
}
all firebase query and adapter is set in setQuery() method..when it is called from onCreateView() it is working...but when it is called from switch case in onOptionsItemSelected it shows nothing and previous list view also hides
Thanks in Advance :)
java android android-fragments firebase-realtime-database android-listview
java android android-fragments firebase-realtime-database android-listview
edited Nov 23 '18 at 3:26
Ishaan Javali
1,3643821
1,3643821
asked Nov 23 '18 at 2:56
Bishal ImtiazBishal Imtiaz
11
11
IsonOptionsItemSelected()
being called?
– parekhkruti26
Nov 23 '18 at 4:19
Yes..i put toast on it
– Bishal Imtiaz
Nov 23 '18 at 11:16
i forgot to put adapter.stopListening() in setQuery()
– Bishal Imtiaz
Nov 23 '18 at 13:42
add a comment |
IsonOptionsItemSelected()
being called?
– parekhkruti26
Nov 23 '18 at 4:19
Yes..i put toast on it
– Bishal Imtiaz
Nov 23 '18 at 11:16
i forgot to put adapter.stopListening() in setQuery()
– Bishal Imtiaz
Nov 23 '18 at 13:42
Is
onOptionsItemSelected()
being called?– parekhkruti26
Nov 23 '18 at 4:19
Is
onOptionsItemSelected()
being called?– parekhkruti26
Nov 23 '18 at 4:19
Yes..i put toast on it
– Bishal Imtiaz
Nov 23 '18 at 11:16
Yes..i put toast on it
– Bishal Imtiaz
Nov 23 '18 at 11:16
i forgot to put adapter.stopListening() in setQuery()
– Bishal Imtiaz
Nov 23 '18 at 13:42
i forgot to put adapter.stopListening() in setQuery()
– Bishal Imtiaz
Nov 23 '18 at 13:42
add a comment |
1 Answer
1
active
oldest
votes
This is my first answer in centuries so please bear with me. This is not an answer but just pointer to the path towards solution.
Put a break-point at the following points
- onOptionsItemSelected
- case R.id.a_pos
- setQuery()
- setQuery::listView inittialization statement
- setQuery::populateView::donor initialization statement
Run the app. Attach the process with debugger. Now when you click "A+" from options, does it get a response from the server or does it throw an exception?
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440143%2fwant-to-update-the-existing-listview-in-fragment-by-clicking-menuitems%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is my first answer in centuries so please bear with me. This is not an answer but just pointer to the path towards solution.
Put a break-point at the following points
- onOptionsItemSelected
- case R.id.a_pos
- setQuery()
- setQuery::listView inittialization statement
- setQuery::populateView::donor initialization statement
Run the app. Attach the process with debugger. Now when you click "A+" from options, does it get a response from the server or does it throw an exception?
add a comment |
This is my first answer in centuries so please bear with me. This is not an answer but just pointer to the path towards solution.
Put a break-point at the following points
- onOptionsItemSelected
- case R.id.a_pos
- setQuery()
- setQuery::listView inittialization statement
- setQuery::populateView::donor initialization statement
Run the app. Attach the process with debugger. Now when you click "A+" from options, does it get a response from the server or does it throw an exception?
add a comment |
This is my first answer in centuries so please bear with me. This is not an answer but just pointer to the path towards solution.
Put a break-point at the following points
- onOptionsItemSelected
- case R.id.a_pos
- setQuery()
- setQuery::listView inittialization statement
- setQuery::populateView::donor initialization statement
Run the app. Attach the process with debugger. Now when you click "A+" from options, does it get a response from the server or does it throw an exception?
This is my first answer in centuries so please bear with me. This is not an answer but just pointer to the path towards solution.
Put a break-point at the following points
- onOptionsItemSelected
- case R.id.a_pos
- setQuery()
- setQuery::listView inittialization statement
- setQuery::populateView::donor initialization statement
Run the app. Attach the process with debugger. Now when you click "A+" from options, does it get a response from the server or does it throw an exception?
answered Nov 23 '18 at 5:53
Muzammil SaeedMuzammil Saeed
145
145
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440143%2fwant-to-update-the-existing-listview-in-fragment-by-clicking-menuitems%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is
onOptionsItemSelected()
being called?– parekhkruti26
Nov 23 '18 at 4:19
Yes..i put toast on it
– Bishal Imtiaz
Nov 23 '18 at 11:16
i forgot to put adapter.stopListening() in setQuery()
– Bishal Imtiaz
Nov 23 '18 at 13:42