数据已经从数据库返回结果,却没在窗口显示出来,大神帮我看一下.

这是在MainActivity的显示方法

 public class MainActivity extends AppCompatActivity {
    private  ListView listView;
    private PersonService personService;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        personService = new PersonService(this);
        listView = (ListView) findViewById(R.id.listView);
        show();
        }

    private void show() {
        List<Person> personList = personService.getScrollDate(1, 20);
        List<HashMap<String,Object>> data= new ArrayList<HashMap<String, Object>>();
        HashMap<String,Object> item;
        for(Person person:personList)
        {
            item = new HashMap<String,Object>();
            item.put("id",person.getId());
            item.put("name",person.getName());
            item.put("phone", person.getPhone());
            data.add(item);
        }
        //适配器用来实现数据与条目,条目与listView的绑定。
        SimpleAdapter simpleAdapter = new SimpleAdapter(this,data,R.layout.item,new String[]{"id","name","phone"},new int[]{R.id.id,R.id.name,R.id.phone});
        listView.setAdapter(simpleAdapter);
    }

这是item.xml内容

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

    <TextView
        android:layout_width="150dip"
        android:layout_height="wrap_content"
        android:id="@+id/id"
        />
    <TextView
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:id="@+id/name"
        />
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/phone"
        />
</LinearLayout>

这是activity_main.xml内容

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        >

        <TextView
            android:layout_width="150dip"
            android:layout_height="wrap_content"
            android:text="@string/id"
            />
        <TextView
            android:layout_width="100dip"
            android:layout_height="wrap_content"
            android:text="@string/name"
            />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/phone"
            />


    </LinearLayout>
<ListView
    android:background="#ff0000"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/listView"
    />

</LinearLayout>

先打印data出来看看有没有数据,我猜你没成功获取数据

图片说明

图片说明

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        >

        <TextView
            android:layout_width="150dip"

你的activity_main.xml中的第一个字控件LinearLayout的高度设为match_parent,下面的Listview当然看不到了

啊啊大神大神大神大神的

asdasdasdasdasd日晷啊实打实大飒飒大