I\'m trying to develop a simple app using Android Scripting and Python.
Now, I have a phone number, and I want to find out which contact has that number. I can do a con
package com.slk.example.CursorActivity;
import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.Phones;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;
public class CursorActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Cursor contactsCursor = this.managedQuery(Phones.CONTENT_URI, null, null, null, null);
this.setListAdapter(new MyContactsAdapter(this,contactsCursor));
}
private class MyContactsAdapter extends CursorAdapter{
private Cursor mCursor;
private Context mContext;
private final LayoutInflater mInflater;
public MyContactsAdapter(Context context, Cursor cursor) {
super(context, cursor, true);
mInflater = LayoutInflater.from(context);
mContext = context;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView t = (TextView) view.findViewById(R.id.txtName);
t.setText(cursor.getString(cursor.getColumnIndex(Phones.NAME)));
t = (TextView) view.findViewById(R.id.txtDisplayName);
t.setText(cursor.getString(cursor.getColumnIndex(Phones.DISPLAY_NAME)));
t = (TextView) view.findViewById(R.id.txtPhone);
t.setText(cursor.getString(cursor.getColumnIndex(Phones.NUMBER)));
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view = mInflater.inflate(R.layout.main, parent, false);
return view;
}
}
}