Android AutocompleteTextView setText或setHint不工作
因此,在我的第一个活动中,我通过反向地理编码将当前位置作为currentLocation,并使用SharedReference将值传递给下一个活动second.java/class。此类由一个autocompleteTextView组成,其值存储在数组中 现在我想要的是,当用户从第一个活动转到第二个活动时,autocompleteTextView应该包含从第一个类获得的位置作为提示或文本 这是我的第一个class.java 还有我的secondclass.java 这是我的XMLAndroid AutocompleteTextView setText或setHint不工作,android,sharedpreferences,autocompletetextview,settext,Android,Sharedpreferences,Autocompletetextview,Settext,因此,在我的第一个活动中,我通过反向地理编码将当前位置作为currentLocation,并使用SharedReference将值传递给下一个活动second.java/class。此类由一个autocompleteTextView组成,其值存储在数组中 现在我想要的是,当用户从第一个活动转到第二个活动时,autocompleteTextView应该包含从第一个类获得的位置作为提示或文本 这是我的第一个class.java 还有我的secondclass.java 这是我的XML 它会显示在图形
它会显示在图形视图中,但不会显示在手机中。请尝试此选项,因为您再次输入SharePreference,现在尝试从SharedReference中获取值
curlocation = editor.getString("CurrentPlace","");
替换
curlocation = editor.putString("CurrentPlace","");
与
在XML文件中,它应该是
android:text= "sample text"
android:hint= "sample text"
尝试使用
curlocation = preferences.getString("CurrentPlace","");
而不是
curlocation = editor.putString("CurrentPlace","");
编辑器仅用于存储SharedReference中的值。但是为了只获取SharedReference的用户实例。在设置XT时,是否没有可见的文本,您需要使用editor.getStringCurrentPlace,;你为第二个类设置了正确的contentView了吗?我想你已经使用了setText和sethint,应该是text和hint。对不起,我有点困惑,但是我只在使用editor.getStringCurrentPlace时使用了text和hint,;我得到的方法是getStringString,String对于类型SharedReferences是未定义的。EditorOrry,我得到附加的值,比如说,如果我第一次启动应用程序,我得到aaaa,当我返回并单击next时,我得到aaaa。附加值。有什么想法,我可以冲洗的首选项,一旦它得到?桑迪,你提供的链接不存在。请给我们正确的链接。检查此链接
curlocation = editor.getString("CurrentPlace","");
curlocation = editor.getString("CurrentPlace",null);
android:text= "sample text"
android:hint= "sample text"
curlocation = preferences.getString("CurrentPlace","");
curlocation = editor.putString("CurrentPlace","");