Я новичок в шаблоне кинжалов и MVP, и у меня утечка памяти.
Я не уверен, что является причиной утечки памяти.
Я думаю, что причина утечки txtCityName
но, возможно, моя ошибка в кинжале или MVP.
Если вам нужно больше подробностей, чтобы ответить, прокомментируйте, пожалуйста.
@OnClick(R.id.constraintLayoutCity)
void onCityClick() {
searchPresenter.getCity();
}
public void getCity() {
cities = new CharSequence[]{"manchester", "london", "madrid", "barcelona"};
adb.setSingleChoiceItems(cities, 0,(d, n) -> {
selectedCity = n;
view.setCity(cities[n].toString());
d.dismiss();
});
adb.setTitle("select a city");
adb.show();
}
public void setCity(String city) {
txtCityName.setText(city);
}
LeakingInstance(referenceKey=7b6a8af5-1103-44d0-91c4-5cb25597d2a2, referenceName=, instanceClassName=androidx.constraintlayout.widget.ConstraintLayout, watchDurationMillis=5151, excludedLeak=false, leakTrace=
┬
├─ ir.reservs.reservs.ui.main.search.SearchFragment
│ Leaking: NO (Fragment#mFragmentManager is not null)
│ ↓ SearchFragment.txtCityName
│ ~~~~~~~~~~~
├─ androidx.appcompat.widget.AppCompatTextView
│ Leaking: YES (View#mAttachInfo is null)
│ View.mID=R.id.txtCityName (2131362166)
│ View.mWindowAttachCount=1
│ ↓ AppCompatTextView.mParent
├─ androidx.constraintlayout.widget.ConstraintLayout
│ Leaking: YES (View#mAttachInfo is null)
│ View.mID=R.id.constraintLayoutCity (2131361908)
│ View.mWindowAttachCount=1
│ ↓ ConstraintLayout.mParent
╰→ androidx.constraintlayout.widget.ConstraintLayout
Leaking: YES (RefWatcher was watching this)
, retainedHeapSize=null)```
Я прочитал, что причиной утечки памяти в текстовом просмотре является вывод текста из экрана.но в моем случае мой текстовый просмотр в нужном месте.так что я не думаю, что утечка для этого.
установить на прослушиватель кликов на макете ограничения есть проблема?