详细文本颜色中的主/详细信息listView是看不见的



我有一个由ADT 2.3.3生成的主/详细视图活动,我在详细信息片段上添加了一个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);

列表视图显示在详细视图中,但所有项目都有文本不可见:

结果

我在此线程中发现,如果在适配器上发送了不正确的上下文,但找不到正确的上下文。

这是我的细节布局,以防万一:

<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" />

现在与侧菜单正确对齐。

最新更新