2017-09-17 1 views
0

나는 다음과 같이 내가 세부 조각 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에서 발견

Result

을 올바른 컨텍스트.

이는 경우 내 상세 레이아웃이 필요하다 :

<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

+0

어댑터를 설정 했습니까? – ZeekHuge

+0

@ ZeekHuge 감사합니다. 방금 setAdapter 파트를 내 게시물에 추가하여 완성되었습니다. – Linderoth

+0

문제가 해결되었다는 뜻입니까? – ZeekHuge

답변

0

을 사용하고

난 그냥 대답을 발견하고는 컨텍스트와는 아무 상관이 없었다. 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" /> 

을 올바르게 사이드 메뉴로 정렬되어 다음과 같이

나는 내 ListView에 레이아웃을 변경했습니다.

관련 문제