Master/Detail 流ListView中的Detail text Color是不可见的
Master/Detail flow ListView in Detail text Color is invisible
我有一个由 ADT 2.3.3 生成的 Master/Detail 视图 Activity,我在其中添加了一个 ListView onCreateView 的详细信息片段,如下所示:
ListView myListView = (ListView)rootView.findViewById(R.id.customer_type_list);
final ArrayList<String> myFamily = new ArrayList<String>();
myFamily.add("Rob");
myFamily.add("Kirsten");
myFamily.add("Tommy");
myFamily.add("Ralphie");
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
android.R.layout.simple_list_item_1,
myFamily);
myListView.setAdapter(arrayAdapter);
列表视图显示在详细信息视图中,但所有项目的文本都不可见:
Result
我在此 thread 中发现,如果在适配器上发送了不正确的上下文但找不到正确的上下文,则可能会发生这种情况。
这是我的详细布局,以备不时之需:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="mx.com.megcloud.placacentro.Home">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/customer_type_list"
android:layout_width="1008dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="mx.com.megcloud.placacentro.Login"
android:layout_marginStart="8dp">
<EditText
android:id="@+id/customer_type_te"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Tipo de cliente"
android:inputType="textPersonName" />
<EditText
android:id="@+id/percentage_te"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="% de comision"
android:inputType="number" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="%"
android:textSize="30sp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="addCustomerType"
android:text="Agregar" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
希望你能帮助我。
我正在使用 API 25
刚刚找到答案,与上下文无关。我意识到 ListView 上的线条一直向左延伸,在到达侧边菜单之前它们应该结束几个像素。
我的 ListView 位于侧边菜单下方,因此文本似乎不可见,但实际上它一直在那里。
我按如下方式更改了 ListView 布局:
<ListView
android:id="@+id/customer_type_list"
android:layout_width="1008dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent" />
现在与侧边菜单正确对齐。
我有一个由 ADT 2.3.3 生成的 Master/Detail 视图 Activity,我在其中添加了一个 ListView onCreateView 的详细信息片段,如下所示:
ListView myListView = (ListView)rootView.findViewById(R.id.customer_type_list);
final ArrayList<String> myFamily = new ArrayList<String>();
myFamily.add("Rob");
myFamily.add("Kirsten");
myFamily.add("Tommy");
myFamily.add("Ralphie");
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
android.R.layout.simple_list_item_1,
myFamily);
myListView.setAdapter(arrayAdapter);
列表视图显示在详细信息视图中,但所有项目的文本都不可见:
Result
我在此 thread 中发现,如果在适配器上发送了不正确的上下文但找不到正确的上下文,则可能会发生这种情况。
这是我的详细布局,以备不时之需:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="mx.com.megcloud.placacentro.Home">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/customer_type_list"
android:layout_width="1008dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="mx.com.megcloud.placacentro.Login"
android:layout_marginStart="8dp">
<EditText
android:id="@+id/customer_type_te"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Tipo de cliente"
android:inputType="textPersonName" />
<EditText
android:id="@+id/percentage_te"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="% de comision"
android:inputType="number" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="%"
android:textSize="30sp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="addCustomerType"
android:text="Agregar" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
希望你能帮助我。
我正在使用 API 25
刚刚找到答案,与上下文无关。我意识到 ListView 上的线条一直向左延伸,在到达侧边菜单之前它们应该结束几个像素。
我的 ListView 位于侧边菜单下方,因此文本似乎不可见,但实际上它一直在那里。
我按如下方式更改了 ListView 布局:
<ListView
android:id="@+id/customer_type_list"
android:layout_width="1008dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent" />
现在与侧边菜单正确对齐。