我在我的应用程序中有一个列表视图,我想突出显示一个列表项而不触摸它。我希望第一项总是突出显示。我该怎么做?
这是我的列表视图代码:
编辑

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.listmenu);

        menuList = (ListView) findViewById(R.id.list1);
    menuList.setAdapter(new ArrayAdapter<String>(this,R.id.list_content, heading));
    menuList.setSelection(1);
    View v = menuList.getSelectedView();
v.requestFocus();

 }

最佳答案

你可以试试

ArrayAdapter<String> adapter;

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.listmenu);

    menuList = (ListView) findViewById(R.id.list1);
    adapter = new ArrayAdapter<String>(this,R.id.list_content, heading);
    menuList.setAdapter(adapter);
    menuList.setSelection(1);

    adapter.getView(0, null, menuList).setFocused(true);

 }

09-26 18:00