Reputation: 1437
Here is the context..
When my app is getting loaded frag A will be loaded having a AutoCOmpletetextview and a textView on selecting item from AutoCOmpletetextview I'm assigning a value in to textview --which is working fine
From NavigationDrawer when navigate to Frag B (Where I have same 1auto complete text view and text box same type functionality).. when I come back to Frag and select item of autcompletetextview value is getting to textview because I can see in toast but still I cannot view it (its empty)..when I run
Where as this case is working fine in frag B i.e when I again navigate back to frag B from A this is working fine i,e I can see value in that textview(as I have same autocomplete and textview even there too)
Here is my AutoCOmplete OnItemClickListener code
objAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TextView objTextView = (TextView) view;
CommonMethods.showLongToast(getActivity(), objTextView.getText().toString());
TextView KText = (TextView) getActivity().findViewById(R.id.txt_K);
KText.setText("some value based in my logic by passing my objTextView.getText()");
CommonMethods.showLongToast(getActivity(),KText.getText().toString()); //I'm able to see value in toast
}
});
Upvotes: 0
Views: 290
Reputation: 1437
I was able to solve problem by replacing this
TextView KText = (TextView) getActivity().findViewById(R.id.txt_K);
with
TextView KText = (TextView) myView.findViewById(R.id.txt_K);
where myView is the view that I have inflated in onCreate method of fragment
final View myView = inflater.inflate(R.layout.fragA, container, false);
Upvotes: 1