我在采用ListView显示数据的时候、有2个字段都显示为fasle、使用的是SimpleAdapter适配器。
Debug发现读取出来的数据都是正常的。 SimpleAdapter sa = new SimpleAdapter(this, students, R.layout.item,
new String[] { "name", "sex", "age" }, new int[] { R.id.name,
R.id.sex, R.id.age });
listView.setAdapter(sa);经过适配器处理就成ffalse是啥原因?难道不能有中文吗?

解决方案 »

  1.   

    重写下simpleAdapter看看,  之前学习的时候,我是拿中文测试的 . 所以肯定支持中文的
      

  2.   

    不是中文的问题,SimpleAdapter 也没写错,Debug发现读取出来的数据都是正常的,也就是数据库也不会出错,那么出错的地方 很可能是 读取数据库那块,用while 循环先把数据放到HashMap 中,再放到Arraylist中,楼主你仔细看看这块; 不行就发上来看看
      

  3.   

    不是中文的问题,SimpleAdapter 也没写错,Debug发现读取出来的数据都是正常的,也就是数据库也不会出错,那么出错的地方 很可能是 读取数据库那块,用while 循环先把数据放到HashMap 中,再放到Arraylist中,楼主你仔细看看这块; 不行就发上来看看
      

  4.   

    检查一下students数据源有没有问题。
      

  5.   

    private void show() {
    // TODO Auto-generated method stub
    List<Student> list = db.getScrollData(0, 20);
    List<HashMap<String, Object>> students = new ArrayList<HashMap<String, Object>>();
    for (Student student : list) {
    HashMap<String, Object> hash = new HashMap<String, Object>();
    hash.put("_id", student.get_id());
    hash.put("name", student.getName());
    hash.put("sex", student.getSex());
    hash.put("age", student.getAge());
    students.add(hash);
    }
    SimpleAdapter sa = new SimpleAdapter(this, students, R.layout.item,
    new String[] { "name", "sex", "age" }, new int[] { R.id.name,
    R.id.sex, R.id.age });
    listView.setAdapter(sa); }
    这是我activity里面的显示方法、我的意思是我debug到循环完成之后students里面的数据都是正常的。会不会和API、ADT之类的版本有关系?
      

  6.   

            SimpleAdapter sa = new SimpleAdapter(this, students, R.layout.item,
                    new String[] { "name", "sex", "age" }, new int[] { R.id.name,
                            R.id.sex, R.id.age });
            listView.setAdapter(sa);到这里执行之前数据都正常、我总不能打断点打到源码里面去吧、
      

  7.   

    觉得是你eclipse编码的问题  你log下看看是不是乱码。顺便把配置文件发上来看看
      

  8.   

    高端啊。、这都能看出来。是看那个视频了再自己敲的。没log过。但是在debug窗口显示不是乱码的、跟配置文件没啥关系吧
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.sqlite"
        android:versionCode="1"
        android:versionName="1.0" >    <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="15" />    <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            
            <provider android:name=".StudentProvider" android:authorities="com.devil.provider.student">
            </provider>
            <activity
                android:name=".SQLiteActivity"
                android:label="@string/title_activity_sqlite" >
                <meta-data
                    android:name="android.support.PARENT_ACTIVITY"
                    android:value="sql" />            <intent-filter>
                    <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>        <uses-library android:name="android.test.runner" />
        </application>    <instrumentation
            android:name="android.test.InstrumentationTestRunner"
            android:targetPackage="com.example.sqlite" /></manifest>
    <?xml version="1.0" encoding="utf-8"?>
    <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:textSize="22sp"
            android:layout_width="120dp"
            android:layout_height="wrap_content"
            android:id="@+id/name" />    <TextView
            android:textSize="22sp"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:text="@+id/sex" />    <TextView
            android:textSize="22sp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@+id/age" /></LinearLayout>
      

  9.   

    <TextView
            android:textSize="22sp"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:text="@+id/sex" />    <TextView
            android:textSize="22sp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@+id/age" />android:text="@+id/sex",android:text="@+id/age"应该是这里的问题,将text改成id试试,楼主用android:text指定id,R文件竟然还能生成sex和age这两个id,很神奇……汗,可能是其他地方指定id时也用了sex和age吧
      

  10.   

        <TextView
            android:textSize="22sp"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:text="@+id/sex" />    <TextView
            android:textSize="22sp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@+id/age" />
    就是他们错了,应该是id