ListView를 작동 시키려고하는데 응용 프로그램을 닫아야하는 화면에 메시지가 표시됩니다! 오류를 찾고 있는데 아무 것도 찾을 수 없습니다! 레이아웃 안에있는 것일까 요? ListView를 거기에 넣어야하는지, 아니면 이것이 CDynamic으로 작성해야하는지 잘 모르겠다. 내가 도대체 뭘 잘못하고있는 겁니까? 또한 onClick 메서드를 사용할 것입니다.하지만이 경우에는 광부 문제가있는 것 같습니다. 일부 도움을 preciate! 감사!ListView 강제 종료 응용 프로그램
public class Activity_3 extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] projection = {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone._ID};
// Get a cursor with all people
Cursor cursor = managedQuery(ContactsContract.Contacts.CONTENT_URI,
projection, null, null, null);
startManagingCursor(cursor);
ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.activity_3, cursor, new String[] {ContactsContract.Contacts.DISPLAY_NAME}, new int[] {R.id.contactItem });
setListAdapter(adapter);
}
}
레이아웃
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/contactList"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView android:id="@+id/contactItem" >
</TextView>
</LinearLayout>
DDMS 오류 로그를 게시 해주십시오. logcat 창을 열고 앱 필터를 추가하십시오. 그런 다음 오류를 볼 수 있습니다. 또한 레이아웃 XML이 불완전한 것 같습니다. 어떤 IDE를 사용하고 있습니까? – Timmetje
SimpleCursorAdapter 또는 baseadapter를 확장하는 ur adapterclass는 어디입니까? – saran
List Activity를 확장하는 경우 레이아웃에 listview를 넣지 않아도됩니다. – Anukool