Log.v("break", "实例化ss成功");
int a = cursor.getColumnCount();
Log.v("break", "实例化a成功");
int b = cursor.getCount();
TextView text = (TextView)findViewById(R.id.text);
Log.v("break", "实例化b成功");
text.setText("行名是:"ss ",列数是:" a ",行数是:" b);
Log.v("break", "text显示成功");
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
MainActivity.this,
R.layout.line, cursor,
new String[] {"_id", "content"},
new int[] {R.id.text0, R.id.text},
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
Log.v("break", "绑定成功");
list.setAdapter(adapter);
Log.v("breakthrough", "成功运行");
}
}
xml代码:
activity_main.xml
<LinearLayout xmlns:android=""
xmlns:tools=""
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation = "vertical">
<TextView
android:id = "@id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<ListView
android:id = "@id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
line.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id = "@id/text0"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"/>
<TextView
android:id = "@id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>第八步:看结果。

本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-47593-3.html
0
全面备战搞点气势出来
英语系毕业也只能如此