Unable to start activity
ComponentInfo{com.example.android/com.example.android.editvehicle}:
.lang.NullPointerException: Attempt to invoke virtual method
-'android.text.Editable android.widget.EditText.getText()' on a null object reference
Not able to get edit text value from one activity to anohter.
public class editvehicle extends Activity {
public static String NAMESPACE="http://tempuri.org/";
static String URL=MainActivity.URL;
public static String METHOD_NAME="updatevehicle";
public static String SOAP_ACTION="http://tempuri.org/updatevehicle";
public static String id;
ArrayList<String> listarray = new ArrayList<String>();
EditText e2,e3,e4,e5,e6,e7;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.editvehicle);
e2 = (EditText) findViewById(R.id.editvehiclenoet);
e3 = (EditText) findViewById(R.id.editvehicletypeet);
e4 = (EditText) findViewById(R.id.editrcnoet);
e5 = (EditText) findViewById(R.id.editpucet);
e6 = (EditText) findViewById(R.id.editpucpicet);
e7 = (EditText) findViewById(R.id.editinsuranceet);
b1 = (Button)findViewById(R.id.edituservehiclebutn);
e2.setText(addvehicle.e2.getText().toString());
e3.setText(addvehicle.e3.getText().toString());
e4.setText(addvehicle.e4.getText().toString());
e5.setText(addvehicle.e5.getText().toString());
e6.setText(addvehicle.e6.getText().toString());
e7.setText(addvehicle.e7.getText().toString());
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new updatevehicle().execute();
}
});
}
public class updatevehicle extends AsyncTask<Void, Void, String> {
ProgressDialog dialog;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog = new ProgressDialog(editvehicle.this);
dialog.setTitle("Loading");
dialog.setMessage("Please Wait ..");
dialog.setIcon(R.drawable.ic_launcher);
dialog.show();
}
@Override
protected String doInBackground(Void... arg0) {
// TODO Auto-generated method stub
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//request.addProperty("id",listarray.get(posi).split("-")[0].trim());
//request.setProperty(e2.setText(););
request.addProperty("id",id.split("-")[0].trim());
request.addProperty("username",MainActivity.username);
request.addProperty("vehicle_no", addvehicle.e2.getText().toString());
request.addProperty("vehicle_type", addvehicle.e3.getText().toString());
request.addProperty("rc_no", addvehicle.e4.getText().toString());
request.addProperty("puc", addvehicle.e5.getText().toString());
request.addProperty("puc _pic", addvehicle.e6.getText().toString());
request.addProperty("insure_file", addvehicle.e7.getText().toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive resultstr = (SoapPrimitive)envelope.getResponse();
Log.d("message","Message : "+resultstr.toString());
return resultstr.toString();
}
catch(Exception e)
{
e.printStackTrace();
Log.e("ERROR", e.toString());
return e.getMessage();
}
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
dialog.dismiss();
Toast.makeText(editvehicle.this, "Vehicle Added", 1).show();
String[] col = result.split("-"); // rows split by ,
listarray.clear();
for(int i =0;i<col.length;i++)
{
//String col[]= rows[i].split("-");
//Buses bus = new Buses(col[1],col[2],col[3],col[4],col[5],col[6]);
//Buse.add(bus);
//listarray.clear();
//listarray.add(col[0]);
/* e2.setText(col[2]);
e3.setText(col[3]);
e4.setText(col[4]);
e5.setText(col[5]);
e6.setText(col[6]);
e7.setText(col[7]);
*/listarray.add(col[i]);
//listarray.add(col[2]); //add in array represent the each rows
//listarray.add(col[1]);
//listarray.add(col[2]);
//listarray.add(col[3]);
//listarray.add(col[4]);
//listarray.add(col[5]);
//listarray.add(col[6]);
}
finish();
}
}
}