[英]findViewById returns null for EditText passing values from one class to another class by using functions
findViewById
returns null
for EditText
passing values from one class to another class 对于将EditText
从一个类传递到另一个类的EditText
findViewById
返回null
public void HandleSearchButtonValue(int START_INDEX,int places,String featurea){
try {
EditText locationEdit=(EditText)findViewById(places);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(locationEdit.getWindowToken(), 0);
String locationAddress =locationEdit.getText().toString();
findViewById
returns the first child view matching the ID. findViewById
返回与ID匹配的第一个子视图。
If you are calling it in an Activity
, the android.R.id.content
View (the one you set with setContentView
) is used as parent, so only views are returned which are in the current Layout. 如果您在Activity
中调用它,则android.R.id.content
视图(使用setContentView
设置的视图)将用作父视图,因此仅返回当前Layout中的视图。
Please provide more information about the caller and the holding class of this method for further help. 请提供有关此方法的调用方和保持类的更多信息,以获取更多帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.