У меня есть фрагмент детали, где у меня есть несколько элементов, в основном TextView. У меня также есть CursorLoader, что onLoadFinished должен установить все эти значения в макете.Элементы макета Android xml не обновляются
Например, в этом фрагменте, он выводит этот текст в настоящее время устанавливается на значение, которое я получил от ContentProvider
String dur = this.expected_duration + " " + this.durationUnit;
Log.v(LOG_TAG, "SETTING DURATION " + dur);
if(dur != null || !"".equals(dur)) {
if(durationTextView != null) {
Log.v(LOG_TAG, "SETTING TEXT VIEW " + dur);
durationTextView.setText(dur);
}
}else{
Log.v(LOG_TAG, "FAIL SETTING TEXT VIEW " + dur);
}
Я вижу результат в журнале, но этот результат никогда доходя до фактического TextView.
Я знаю, что это не проблема видимости или шрифта текста. У меня TextView hightlighted в розовом и удостоверился, что макет текста отображается на экране. У меня такое ощущение, что я могу создавать дубликаты фрагментов, которые лежат один поверх другого (не уверен, что это возможно). Я могу полностью создать экземпляр всех TextViews и извлечь все значения, но не могу собрать их на экране. Пожалуйста помоги. Кроме того, если моя теория дублирующих фрагментов правильная, объясните, как вы ее отслеживали. Спасибо.
Мой файл макета (на всякий случай)
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.jennyeckstein.udacitycoursepicker.DetailActivityFragment"
>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scrollView" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/course_subtitle"
tools:text="How to Make an Android App"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/course_layout_detail"
android:layout_below="@id/course_subtitle"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/duration"
android:background="@color/pink"
android:textSize="16sp"
tools:text="333 years"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/course_level"
tools:text="ADVANCED"/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/begin_course_button"
android:text="Go to Udacity"
android:layout_below="@+id/course_layout_detail"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/required_knowledge"
android:layout_below="@id/begin_course_button"
tools:text="If you are new to programming and don’t know where to start"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/required_knowledge"
android:id="@+id/summary"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/summary"
android:background="@color/green"
android:id="@+id/syllabus"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/syllabus"
android:id="@+id/faq"/>
</RelativeLayout>
</ScrollView>
</FrameLayout>
Исходный код на GitHub Repo
Имя макета: fragment_detail.xml и имя Фрагмент: DetailActivityFragment.java
@John_Shea, thanx so much, я полностью пропустил это, и ваше решение полностью сработало. Я прошел через код и его макет, который мне не помог !!! ОТЛИЧНАЯ РАБОТА! – Jenny