I'm using googles source code to build a recent calls look alike activity. I have to create an app with a custom view of the dialer, recent calls and contacts, so my first step was to create a custom dialer. Then, I created a call log, but the appearance wasn't nice enought so I get google's contacts app package to get the RecentCallsActivity and adapt to my app.
Now, I've got almost the app working, but I have some errors that I don't know how to solve. This is a extract of the code with the most relevant parts to try to solve this errors:
public class RecentCallsListActivity extends ListActivity implements View.OnCreateContextMenuListener {
...
RecentCallsAdapter mAdapter;
....
final class RecentCallsAdapter implements ViewTreeObserver.OnPreDrawListener, View.OnClickListener, Runnable {
...
@Override
protected void onCreate(Bundle state) {
super.onCreate(state);
mAdapter = new RecentCallsAdapter();
getListView().setOnCreateContextMenuListener(this);
setListAdapter(mAdapter); // The method SetListAdapter (ListAdapter) in the type ListActivity is not aplicable for the arguments (RecentCallsListActivity.RecentCallsAdapter)
mQueryHandler = new QueryHandler(this);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
AdapterView.AdapterContextMenuInfo menuInfo;
Cursor cursor = mAdapter.getItem(menuInfo.position); //The method getItem(int) is undefined for the type RecentCallsListActivity.RecentCallsAdapter
...
These are the 2 principal errors. In the original file, the mAdapter is declared the same way and there aren't these errors. Also, there are other 2 errors:
mAdapter.isGroupHeader(menuInfo.position)
mAdapter.getGroupSize(menuInfo.position)
It must be some kind of declaration but I don't know why or what to do.
UPDATE
I've solved this extending a class to the adapter thanks to Eugene's answer. But now I have the following problem when implementing some drawables. I know i can't reference to the android.internal.R so the thing would be to find a solution for this:
protected void bindGroupView(View view, Context context, Cursor cursor, int groupSize,
boolean expanded) {
final RecentCallsListItemViews views = (RecentCallsListItemViews) view.getTag();
int groupIndicator = expanded
? com.android.internal.R.drawable.expander_ic_maximized //CANNOT BE RESOLVED
: com.android.internal.R.drawable.expander_ic_minimized; //CANNOT BE RESOLVED
views.groupIndicator.setImageResource(groupIndicator);
views.groupSize.setText("(" + groupSize + ")");
bindView(context, view, cursor);
}
Your adapter does not implement listadapter interface Original adapter extends ResourceCursorAdapter, which already implements ListAdapter
final class RecentCallsAdapter extends ResourceCursorAdapter
implements Runnable, ViewTreeObserver.OnPreDrawListener, View.OnClickListener {
but your adapter does not.
final class RecentCallsAdapter implements ViewTreeObserver.OnPreDrawListener, View.OnClickListener, Runnable
You should either extend some class, either implement ListAdapter
yourself
Other two errors come from same origin - you just don't have such methods, because You haven't implemented them, nor you have extended the class already having them.
Good luck with coding :)