主/从流动的ListView颜色是不可见的
问题描述:
我在哪里加入上的详细片段onCreateView一个ListView如下由ADT 2.3.3中产生的主/查看活动:主/从流动的ListView颜色是不可见的
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);
列表视图显示在详细信息视图,但所有的项目都有文字无形:
我在这个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" />
现在正确地与侧面菜单对齐。
您是否设置了适配器? – ZeekHuge
@ZeekHuge谢谢你,我做到了。我只是将setAdapter部分添加到了我的文章中,因此完成了。 – Linderoth
你的意思是解决了这个问题? – ZeekHuge