无法滚动PreferenceActivity

时间:2014-03-28 19:24:02

标签: android listview sharedpreferences

我正在尝试将自己的项目列表放入PreferenceActivity中,但是我遇到了滚动问题。

public class OverlayPreferencesActivity extends PreferenceActivity {
   @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getFragmentManager().beginTransaction().replace(android.R.id.content, preference).commit();

        String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2", "Android", "iPhone",
                "WindowsMobile" };

        final List<String> list = new ArrayList<String>();
        for (String value : values) {
            list.add(value);
        }

        final ListAdapter adapter = new ListAdapter(this, list);
        setListAdapter(adapter);
    }

自定义适配器:

private class ListAdapter extends ArrayAdapter<String> {

    private List<String> values;

    public ListAdapter(Context context, List<String> values) {
        super(context, android.R.layout.simple_list_item_multiple_choice, values);
        this.values = values;
    }

    @Override
    public String getItem(int index) {
        return values.get(index);
    }

    @Override
    public long getItemId(int index) {
        return index;
    }
}

我不知道为什么我不能滚动列表。实际上,似乎没有任何触摸事件在列表中起作用。

0 个答案:

没有答案