How can I getText() from EditText in Fragment and pass in Volley Parameters? <p>I am using Volley in Fragments for the first time.</p> <p>Can anyone help me with this. I am trying this following code for the fragment which I am calling from a navigation drawer:</p> <pre><code>public class ChangePassword extends android.app.Fragment implements View.OnClickListener { EditText etOldSignUpPassword; EditText etNewSignUpPassword; EditText etNewSignUpConfirmPassword; ImageButton imageChangePasswordButton; ProgressBar pbWeb; String old,npass,ncpass; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_change_password, container, false); etOldSignUpPassword = (EditText)v.findViewById(R.id.etOldPassword); etNewSignUpPassword = (EditText)v.findViewById(R.id.etNewSignUpPassword); etNewSignUpConfirmPassword = (EditText)v.findViewById(R.id.etNewSignUpConfirmPassword); imageChangePasswordButton = (ImageButton)v.findViewById(R.id.imageChangePasswordButton); pbWeb = (ProgressBar)v.findViewById(R.id.pbWebC); pbWeb.setVisibility(View.GONE); imageChangePasswordButton.setOnClickListener(this); return v; } @Override public void onClick(View view) { if(view.getId() == R.id.imageChangePasswordButton) { old = etOldSignUpPassword.getText().toString(); npass = etNewSignUpPassword.getText().toString(); ncpass = etNewSignUpConfirmPassword.getText().toString(); if (!isNetworkAvailable()) { Toast.makeText(getActivity(), "Your Wifi/Data is disabled. Please switch on and try again", Toast.LENGTH_SHORT).show(); } else { pbWeb.setVisibility(View.VISIBLE); String server_url = "url_working_fine_for_activity_so_no_issue_here"; StringRequest strReq = new StringRequest(Request.Method.POST, server_url, new Response.Listener&lt;String&gt;() { @Override public void onResponse(String response) { if (response.equals("SUCCESS")) { Toast.makeText(getActivity(), "Password Changed Successfully", Toast.LENGTH_SHORT).show(); Intent loginIntent = new Intent(getActivity(), LoginActivity.class); startActivity(loginIntent); pbWeb.setVisibility(View.GONE); getActivity().finish(); } else { pbWeb.setVisibility(View.GONE); Toast.makeText(getActivity(), "Couldn't Change Password. Old Password Exists", Toast.LENGTH_SHORT).show(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { pbWeb.setVisibility(View.GONE); Toast.makeText(getActivity(), error.toString(), Toast.LENGTH_SHORT).show(); } }) { @Override protected Map&lt;String, String&gt; getParams() throws AuthFailureError { Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put("old", old);//etOldPassword.getText().toString() throws NullPointerException map.put("new", npass);//"MY_DEFAULT_VALUE" as value is working fine but that is not the use case map.put("newCon", ncpass); return map; } }; //VolleySingleton is fine as working in Activity as well as when I give default values in getParams so no issue in this class VolleySingleton.getInstance(getActivity().getApplicationContext()).addToReqQueue(strReq); } } } </code></pre> <p><strong>PREV:</strong> <em>Currently this code leads to a crash.</em></p> <p><strong>NOTE:</strong> I have tried using onClickListener() directly on imageChangePasswordButton inside onActivityCreated() method without implemeting onClickListener on the class but found on a thread that there is a bug. </p> <p><strong>EDIT:</strong> <em>Current Code as seen is working fine.</em></p> <p>Here is the xml as requested:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".mypackage.ChangePassword"&gt; &lt;!--The class ChangePassword is inside mypackage--&gt; &lt;ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/pbWebC" style="@android:style/Widget.ProgressBar.Small" android:layout_centerInParent="true" /&gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentTop="true"&gt; &lt;ImageView android:layout_width="150dp" android:layout_height="150dp" android:src="@drawable/image1" android:id="@+id/logo" android:layout_gravity="center_horizontal" /&gt; &lt;EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword" android:hint="@string/prompt_old_email" android:ems="10" android:layout_marginTop="10dp" android:id="@+id/etOldPassword" /&gt; &lt;EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword" android:hint="@string/prompt_new_password" android:ems="10" android:layout_marginTop="10dp" android:id="@+id/etNewSignUpPassword" /&gt; &lt;EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword" android:hint="@string/prompt_new_confirm_password" android:ems="10" android:layout_marginTop="10dp" android:id="@+id/etNewSignUpConfirmPassword" /&gt; &lt;ImageButton android:layout_width="150dp" android:layout_height="50dp" android:layout_gravity="center" android:id="@+id/imageChangePasswordButton" android:layout_marginTop="20dp" android:src="@drawable/reset" /&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p><strong>EDIT:</strong> <em>Code working fine. Thanks for the help. @LongRanger @i-Droid</em></p>