したがって、「final int sortColumnIndex = c.getColumnIndex(YOUR_SORT_COLUMN_NAME);」という 3 つのエラーが発生します。& "public class MyAdapter extends CursorAdapter implements SectionIndexer" <--- これは 2 回エラーとしてマークされています。
私の MainActivityNext.java
package testing.android.application.three;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import android.os.Bundle;
import android.support.v4.widget.CursorAdapter;
import android.widget.AlphabetIndexer;
import android.widget.ArrayAdapter;
import android.widget.SectionIndexer;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor;
public class MainActivityNext extends ListActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity_next);
}
public class MyAdapter extends CursorAdapter implements SectionIndexer
{
// All valid characters. May want to include numbers, etc if they show up
// in your sort column
private final static String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
private AlphabetIndexer mIndexer = null;
public MyAdapter(Context context, Cursor c, int flags)
{
super(context, c, flags);
// Assumes your cursor is non-null,
// otherwise do this in swapCursor if mIndexer==null
final int sortColumnIndex = c.getColumnIndex(YOUR_SORT_COLUMN_NAME);
mIndexer = new AlphabetIndexer(c, sortColumnIndex,
ALPHABET);
}
public Cursor swapCursor(Cursor newCursor)
{
super.swapCursor(newCursor);
// Make sure the AlphabetIndexer knows about the new Cursor
mIndexer.setCursor(newCursor);
return newCursor;
}
public int getPositionForSection(int section)
{
// AlphabetIndexer does all the hard work
return mIndexer.getPositionForSection(section);
}
public int getSectionForPosition(int position)
{
// AlphabetIndexer does all the hard work
return mIndexer.getSectionForPosition(position);
}
public Object[] getSections()
{
// AlphabetIndexer does all the hard work
return mIndexer.getSections();
}
}
}