2014-05-01 8 views
-1

Top 뷰로 설정하면 텍스트가 검은 색으로 표시되지만 RelativeLayout과 같은 다른 레이아웃에 중첩되면 텍스트가 흰색/투명이됩니다. 선형 레이아웃으로 배치하려고 시도했지만 동작이 변경되지 않았습니다. 다음은 상대 레이아웃의 목록 뷰가 투명하게됩니다.

는 XML 파일입니다

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

<Button 
    android:id="@+id/purchaseBtn" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@+id/list_view" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="78dp" 
    android:text="@string/purchase" /> 

<ListView 
    android:id="@+id/list_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/header" > 
</ListView> 

<Button 
    android:id="@+id/menuReturnBtn" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@+id/purchaseBtn" 
    android:layout_centerHorizontal="true" 
    android:text="@string/productMenu" /> 

<TextView 
    android:id="@+id/header" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:text="@string/checkoutHeader" 
    android:textAppearance="?android:attr/textAppearanceLarge" /> 

    </RelativeLayout> 

그리고 여기 목록보기 설정하는 활동이다 : https://drive.google.com/file/d/0BwxIRxqhBpk3amlELVJ4SHZndWs/edit?usp=sharing

+0

bi 어댑터에 대해'getView()'메소드를 구현 한 곳을 알려줄 수 있습니까? 귀하의 목록보기에 nded? – rperryng

+0

@Rperryng 뷰와 어댑터를 설정하는 활동을 추가했습니다. –

답변

0
: 여기
public class Checkout extends Activity implements OnItemClickListener { 

     private MasterDatabaseAdapter db; 
     private Button checkoutBtn; 
     private Button menuReturnBtn; 
     private ListView list; 
     private List<String> orderArray; 
     private StringTokenizer tokens; 

     @Override 
     public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.checkout_orders); 

      // initiate database 
      db = new MasterDatabaseAdapter(getApplicationContext()); 

      checkoutBtn = (Button) findViewById(R.id.checkoutBtn); 
      menuReturnBtn = (Button) findViewById(R.id.menuReturnBtn); 
      list = (ListView) findViewById(R.id.list_view); 

      // setup order list 
      orderArray = new ArrayList<String>(); 
      getReceipt(); // fills up orderArray with receipt output 
      ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, orderArray); 
      list.setAdapter(adapter); 
      list.setOnItemClickListener(this); 

      // navigate to product menu 
      menuReturnBtn.setOnClickListener(new OnClickListener() { 

       @Override 
       public void onClick(View v) { 
        db.closeDB(); 
        Intent launchMenu = new Intent(Checkout.this, 
        ProductMenu.class); 
        startActivity(launchMenu); 

       } 
      }); 


     } 

     @Override 
     public void onItemClick(AdapterView<?> parent, View view, int position, 
       long id) { 

      String code; 
      String viewString = ((TextView) view).getText().toString(); 
      tokens = new StringTokenizer(viewString); 

      // iterate through list view text 
      tokens.nextToken(); // skip code label 
      code = tokens.nextToken(); // product code value 

      // close database before navigating 
      db.closeDB(); 

      Intent launchOrderItem = new Intent(Checkout.this, 
        OrderItem.class); 
      launchOrderItem.putExtra("code", code); // pass code to another activity 
      startActivity(launchOrderItem); // launch new activity 

     } 

     // displays receipt of ordered items 
     public List<String> getReceipt(){ 
      String temp = ""; 
      Product item = null; 

      // fetch list of products 
      List<Product> products = db.getAllProducts(); 
      Log.i("Checkout", "fetched all products + count=" + products.size()); 
      // get iterator for product list 
      Iterator<Product> iterator = products.iterator(); 
      while (iterator.hasNext()){ 
       item = iterator.next(); 
       // format receipt display before outputting 
       temp = "CODE: " +item.getCode() + " @R"+item.getPrice() +" x"+db.countOrders(item.getCode()); 
       Log.i("Checkout", temp); 
       orderArray.add(temp); 
      } 

      Log.i("Checkout", "Size of orderArray: "+orderArray.size()); 
      return orderArray; 

     } 

    } 

출력의 스크린 샷에 대한 링크입니다
// try this way 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/menu" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/Menu" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <ListView 
     android:id="@+id/list_view" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_marginTop="5dp" 
     android:layout_weight="1"/> 

    <Button 
     android:id="@+id/basketBtn" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:text="@string/basket" /> 

    <Button 
     android:id="@+id/setupBtn" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:text="@string/slaveSetupBtn" /> 

</LinearLayout> 
+0

고맙지 만 문제가 해결되지 않았습니다. 문제를 더 설명하는 데 도움이 될 원래 문제의 스크린 샷을 첨부 했습니까? –

관련 문제