Hello how can I pass two parameters from a fragment to an activity? I tried to do this but I can't. I got only the ref in the TextView editRef but the TextView et_login is empty
public class ResultFragmentC extends Fragment implements ListView.OnItemClickListener {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootview = inflater.inflate(R.layout.fragment_result, container, false);
et_login = (TextView) rootview.findViewById(R.id.et_login);
Intent intent = getActivity().getIntent();
String log = intent.getStringExtra("login");
et_login.setText(log);
......
}
......
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity().getApplicationContext(), ViewResult.class);
HashMap<String, String> map = (HashMap) parent.getItemAtPosition(position);
String tid = map.get("ref");
intent.putExtra("ref", tid);
String tid2 = map.get("log");
intent.putExtra("log", tid2);
startActivity(intent);
}
ViewResult.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_result);
Intent intent = getIntent();
layout=(LinearLayout) findViewById(R.id.layout);
String ref2 = intent.getStringExtra("ref");
et_login = (TextView) findViewById(R.id.et_login);
String log = intent.getStringExtra("log");
et_login.setText(log);
editRef = (TextView) findViewById(R.id.editRef);
editRef.setText(ref2);
}