Hi,
I'm just getting problems with my app'... and really don't understand
all about that.
When I launch my ListActivity I get : "XContacts has stopped
unexpectedly"
XContacts is just a list view of contacts which are saved in phone.
Here is the code, I hope that I'll get some responses because I'm
thinking that I haven't understood something in documentation...
--
XContacts.java
--
package com.test.xcontacts;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.People;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;
public class XContacts extends ListActivity {
private String[] _projection = new String[] {
People.NAME
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contacts_list);
Cursor managedCursor = managedQuery(People.CONTENT_URI,
_projection,
null,
null,
People.NAME + " ASC");
String[] from = new String[] {
People.NAME
};
int[] to = new int[] {
R.id.text1
};
ListAdapter contactsAdapter =
new SimpleCursorAdapter(this,
R.layout.contacts_list_row,
managedCursor, from, to);
setListAdapter(contactsAdapter);
}
}
--
contacts_list.xml
--
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_contacts"/>
</LinearLayout>
--
contacts_list_row
--
<?xml version="1.0" encoding="UTF-8"?>
<TextView android:id="@+id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---