Так что в моем первом занятии я получаю текущее местоположение в качестве CurrentLocation через обратное геокодирование и я использую sharedPreference передать значение для следующей операции (second.java/class). Этот класс состоит из autocompleteTextView, значения которого хранятся в массиве.AutoCompleteTextView SetText или setHint не работает
Теперь то, что я хочу, когда пользователь выходит из первого действия на вторую деятельность AutoCompleteTextView должны содержать положение, полученное из первого класса как намека или Текста
Так что это мой firstclass.java
Toast.makeText(this,currentPlace, 1000).show(); //works
SharedPreferences preferences = getSharedPreferences("myPrefss", getApplicationContext().MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("CurrentPlace", currentPlace);
editor.commit();
и мой secondclass.java
SharedPreferences preferences = getSharedPreferences("myPrefss", getApplicationContext().MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
String curlocation;
from = (AutoCompleteTextView) findViewById(R.id.et_login_form);
curlocation = editor.putString("CurrentPlace","");
from.setText(curlocation); //doesn't work
from.setHint(curlocation); //doesn't work
и это мой XML
<AutoCompleteTextView
android:id="@+id/et_login_form"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:inputType="textMultiLine"
android:textColor="@android:color/black" />
и я попытался установить текст в XML Повсеместно
android:Text= "sample text"
android:Hint= "sample text"
, который показывает в графическом представлении, но не в MobilePhone
Не отображается текст, если вы используете setText() –
Вам необходимо использовать editor.getString («CurrentPlace», «»); –
Вы настроили правильный контент для второго класса? –