【问题标题】:How I see the Full ListView in my Android Application我如何在我的 Android 应用程序中看到完整的 ListView
【发布时间】:2012-10-11 08:41:11
【问题描述】:

我为使用 ListView 测试 Android 应用程序而编写。这个 ListView 我用 ListAdapter 填充,它工作正常。只有当我启动应用程序时,我才看到完整的 ListView :(

这是我的 activity_main.xml

<?xml version="1.0" encoding="utf-8" ?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:orientation="vertical">

   <ListView
       android:id="@+id/listview1"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       ></ListView>

</LinearLayout>

这是我的 MainActivity.java

package de.linde.listview;

import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.app.Activity;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

public class MainActivity extends Activity {

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

        List valueList = new ArrayList<String>(); 

        for(int i=0;i<10;i++)
        {
            valueList.add("value" + i); 
        }

        ListAdapter adapter = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_list_item_1,valueList); 

        final ListView lv = (ListView)findViewById(R.id.listview1);
        lv.setAdapter(adapter); 
    }

}

我做错了什么:(?

【问题讨论】:

  • 尝试在最后一个 lv..setCacheColorHint(0) 中添加代码;

标签: android listview android-intent android-arrayadapter listadapter


【解决方案1】:

你的文字颜色有问题。

尝试改变listviwe的文本颜色或背景颜色。

它肯定会工作。

  <ListView
   android:background="#C0C0C0" <------
   android:id="@+id/listview1"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content">
   </ListView>

【讨论】:

  • 这个属性如何?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-06
  • 2020-07-21
  • 2012-01-26
  • 1970-01-01
  • 2011-11-02
  • 1970-01-01
相关资源
最近更新 更多