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. google gears in webview! (works only in browser)

Two things i can think of.  First make sure your WebChromeClient has
an over ride for onJsAlert.
The next part is tricky.  If you have android 2 you can't use gears/
but u can use the w3c spec for 'navigator.geolocation'. but you still
need to enable a few things in code.
in your webcromeclient again.
override onGeolocationPermissionsShowPrompt
        @Override
        public void onGeolocationPermissionsShowPrompt(String origin,
Callback callback) {
        // TODO Auto-generated method stub
                super.onGeolocationPermissionsShowPrompt(origin, callback);
                callback.invoke(origin, true, false);
        }

next in your activity
        MyWebChromeClient mwcc = new MyWebChromeClient ();
        mWebView.setWebChromeClient(mwcc );
        mwcc.onGeolocationPermissionsShowPrompt('', this);

and make your activity
implements GeolocationPermissions.Callback
and finally
add an invoke for that call back.
        public void invoke(String origin, boolean allow, boolean remember) {
                // TODO Auto-generated method stub

        }

not sure if its 100% safe, but this is what i use.
let me know if you find a way to get gears back in the webview.

-w





-- 

2. Moving from one Activity to another with a pause/delay

Hi All,

I have* two activities*,

*1st one* has a ques and 4 options.

*2nd one* is like a result page (... displaying if your ans is correct or
not ...and showing the right ans ..)

Now what i want is when a user clicks :

on a right option [or wrong option] ..i want to turn that Image button into
green [ red] .*.and wait for a while* ..and then go to the result activity
..

*so my only concern is onclick of a ImageButton ... how to wait for a while
.. and then move to other activity*
*
*
any kind of suggestion will do ..

-- 

3. WebView not loading enough JavaScript that the full Android Browser can.

4. ProgressDialog BackGround

5. About ListView filter

6. Use of AIDL Interfaces for IPC with List of AIDL Interface

7. Retrieve "My contact card" data