I got a problem with edit text...here i will explain regarding my problem
I tried with all other ways but didn't found good solution. Can i know what the fault i have done with... Hope I have given required details to clear my question.If you feel it as insufficient please let me know it..
In fragment....
edt = (EditText) rootView.findViewById(R.id.note);
In fragmentactivity
static EditText edt;
static String a;
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
a = edt.getText().toString();
Log.v("a",""+a);
}
});
I got a good solution for this....in android if you declare editext in fragment and to get values in activity it will give null values but the best part of android is if you dont get it in plan A it will show remaing 25 alphabets...So you have to implement it in anothe manner I will sugest you one implementation remove static from the edittext and keep it in fragment...
edt.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
Editable b=s;
a=b.toString();//use this a where ever you want in activity
}
});
You defined EditText. But did you initialized it by calling findViewById or something?
or did you defined it twice?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.