我正在通过 SQLite 从数据库中获取数据。我将数据记录到数据库并使用 Listview 我想在 xml 中显示数据。但无法启动活动。我是第一次使用 Listview。谢谢你的帮助。
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2180
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2230
ActivityThread.access$600(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 141
ActivityThread$H.handleMessage(Message) line: 1234
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 137
ActivityThread.main(String[]) line: 5039
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 511
ZygoteInit$MethodAndArgsCaller.run() line: 793
ZygoteInit.main(String[]) line: 560
NativeStart.main(String[]) line: not available [native method]
这是java代码;
public class ButceGetirenListView extends ListActivity {
Spinner yil,ay;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
yil=(Spinner)findViewById(R.id.spinnerYillar);
ay=(Spinner)findViewById(R.id.spinnerAylar);
String[] result=getiren();
setListAdapter(new ArrayAdapter<String>(this, R.layout.butcegetir,result));
ListView listV=getListView();
listV.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Toast.makeText(getApplicationContext(),((TextView)arg1).getText(), Toast.LENGTH_SHORT).show();
}
});
}
protected String[] getiren(){
int yillar=Integer.valueOf(yil.getSelectedItem().toString());
String aylar=ay.getSelectedItem().toString();
TemporaryDatabase tdb=new TemporaryDatabase(this);
tdb.open();
String[] result=new String[25];
result = tdb.getDataHesapla(yillar,aylar);
tdb.close();
return result;
}
}
和xml代码:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textViewListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dp">
</TextView>