Daryl
Daryl

Reputation: 95

passing edittext parameter

I tried to call an method from one class to an activity class but im having nullpointer exception on the edittext.

// this is the method i created in method class

public void getEditTextValue(EditText edittext, int resources, String  DataValue , String vEditTextValue) {

            methods md = new methods();
            edittext = (EditText) findViewById(resources);
            vEditTextValue = edittext.getText().toString();
            md.editorSharePreferences(this, DataValue, vEditTextValue);
        }

// i call this method in the main activity class, i declare a public EditText edittext at the beginning of the class

public EditText edittext;

methods md = new methods();

md.getEditTextValue(currentEmployerMonth, R.id.etTimeWithYourCurrentEmployerMonths, "dCurrentEmployerMonth", vCurrentEmployerMonth);    

Upvotes: 0

Views: 1391

Answers (1)

Rohit
Rohit

Reputation: 3408

send edit text value as String and get again in other activity and assign where you want to assign the value of edittext

function (edittext.tostring());

Upvotes: 1

Related Questions