CursorTreeAdapter!!!

by beginner » Tue, 09 Feb 2010 01:42:51 GMT


Sponsored Links
 ello everyone!!!
I'm new android, i'm trying to do with CursorTreeAdapter but it doesnt
work. Please help!!!

Here is my code

import android.app.Activity;

import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Contacts.People;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorTreeAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.TextView;


public class ExpandableList extends Activity {
private int mGroupIdColumnIndex;

private String mPhoneNumberProjection[] = new String[] {
People.Phones._ID, People.Phones.NUMBER
};


private ExpandableListAdapter mAdapter;
private LayoutInflater mInflater;
private LayoutInflater mInflater_group;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.expandable_list);
Cursor groupCursor = managedQuery(People.CONTENT_URI,
new String[] {People._ID, People.NAME},
null,null,null);
mGroupIdColumnIndex =
groupCursor.getColumnIndexOrThrow(People._ID);
ExpandableListView lv = (ExpandableListView)
this.findViewById(R.id.expandable_list);

MyExpandableListAdapter myAdapter = new
MyExpandableListAdapter(groupCursor,this);
lv.setAdapter(myAdapter);

}

public class MyExpandableListAdapter extends CursorTreeAdapter {

public MyExpandableListAdapter(Cursor cursor, Context context)
{
super(cursor,context);
}

@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
Uri.Builder builder = People.CONTENT_URI.buildUpon();
ContentUris.appendId(builder,
groupCursor.getLong(mGroupIdColumnIndex));

builder.appendEncodedPath(People.Phones.CONTENT_DIRECTORY);
Uri phoneNumbersUri = builder.build();
return managedQuery(phoneNumbersUri,
mPhoneNumberProjection, null, null, null);
}

@Override
protected void bindChildView(View view, Context context, Cursor
cursor,
boolean isLastChild) {
TextView id = (TextView) view.findViewById(R.id.text1);
id.setText(People.NUMBER);

}

@Override
protected void bindGroupView(View view, Context context, Cursor
cursor,
boolean isExpanded) {
TextView id = (TextView) view.findViewById(R.id.text1);
id.setText(People.NAME);


}

@Override
protected View newChildView(Context context, Cursor cursor,
boolean isLastChild, ViewGroup parent) {
mInflater = LayoutInflater.from(context);
final View view =
mInflater.inflate(R.layout.expandable_list_item_with_image, parent,
false);
return view;
}

@Override
protected View newGroupView(Context context, Cursor cursor,
boolean isExpanded, ViewGroup parent) {
mIn



Other Threads

1. add new resource when using eclipse plugin

I added a new file "colors.xml" to res/values/ .  That seemed to go OK
but the R.java class was *not* automatically updated.  Is there a
"right" way to add these files?  I just did ctrl-N then selected
"File" and named the file colors.xml.  Then I just typed in the xml
which looks fine.  I looked for something like Android Resource but
saw nothing.

I actually also had this problem when adding images to res/drawable/.
I added two images but they didn't show up.  In that case I said
create new file, link to filesystem and that (strangely) worked and
for some reason the second image showed up.  It was like I just needed
to kick it a little to trigger it to look in that directory.

Is there something I'm missing here?

Thanks in advance for any help.
--~--~---------~--~----~------------~-------~--~----~

2. How to bring back file-explorer window in eclipse-DDMS once after closing it

Window > Show View > Other...
Then you'll find it under "Android".

You can also reset the whole perspective (Window > Reset Perspective)

Xav




--~--~---------~--~----~------------~-------~--~----~

3. http-proxy does not work on emulator when i use the build of master branch with cupcake changes

4. Emulator issue

5. corresponding class ColorSpace and ColorModel in Android

6. Packages inclusion in Android

7. stopSelf() question