0

我正在尝试在我的应用程序中实现一个侧面菜单,它在大多数情况下都可以正常工作,但我遇到的问题是,一旦我显示菜单并尝试向下滚动,整个列表就会变成白色(背景)并且文本消失。

http://i.imgur.com/6a6TgJJ.png

http://i.imgur.com/ykT7hCN.png

上面我附上了两张显示菜单行为的图片,当我将手指从左向右滑动时,侧边菜单会显示,但是如果我在菜单中向下滚动,它会变成一个空的白名单,这是我的代码:

public class ControlApp extends SlidingActivity{

ArrayList<String> datos ;
ArrayAdapter<String> adaptador;
Intent intent;
private String[] mMenuLista;
//  private MyCustomAdapter mAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notificaciones);
    setBehindContentView(R.layout.activity_menu);

    Parse.initialize(this, "BqCCNsbb14MPgeWz3rznxO4DamuXUbsgiTug8P8I", "9j7GSLWnV46fkPsNMwnMD2FormAiclKlGitfDq2b"); 
    ParseAnalytics.trackAppOpened(getIntent());

    getSlidingMenu().setBehindOffset(100);

//      mAdapter = new MyCustomAdapter();



    PushService.setDefaultPushCallback(this, Notificaciones.class);
    ParseInstallation.getCurrentInstallation().saveInBackground();

    mMenuLista =  getResources().getStringArray(R.array.lista_menu);
//      for(int i=0; i<=9;i++){
//          mAdapter.addItem(mMenuLista[i]);
//          if(i == 9){
//              mAdapter.addSeparatorItem(mMenuLista[i]);
//          }
//      }



    ListView primario = (ListView) findViewById(R.id.left_drawer);
    primario.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list, mMenuLista));



    primario.setOnItemClickListener(new OnItemClickListener() { 
        @Override
        public void onItemClick(AdapterView<?> pariente, View view, int posicion, long id) {

            selectItem(posicion);

        }
    });





}

public void selectItem(int posicion){
    switch (posicion) {
    case 0:
        intent = new Intent(ControlApp.this, Notificaciones.class);
        startActivity(intent);
        break;
    case 1:
        intent = new Intent(ControlApp.this, Calificaiones.class);
        startActivity(intent);
        break;
    case 2:
        intent = new Intent(ControlApp.this, Mensajes.class);
        startActivity(intent);
        break;
    case 3:
        intent = new Intent(ControlApp.this, Citas.class);
        startActivity(intent);
        break;
    case 4:
        intent = new Intent(ControlApp.this, Permisos.class);
        startActivity(intent);
        break;
    case 5:
        intent = new Intent(ControlApp.this, Eventos.class);
        startActivity(intent);
        break;
    case 6:
        intent = new Intent(ControlApp.this, Horarios.class);
        startActivity(intent);
        break;
    case 7:
        intent = new Intent(ControlApp.this, Circulares.class);
        startActivity(intent);
        break;
    case 8:
        intent = new Intent(ControlApp.this, ProgramaDeEstudios.class);
        startActivity(intent);
        break;
    case 9:
        intent = new Intent(ControlApp.this, Ajustes.class);
        startActivity(intent);
        break;
    case 10:

        ParseUser.logOut();
        ParseUser currentUser = ParseUser.getCurrentUser();
        if (currentUser == null){
            // sesion cerrada correctamente
            Toast toast = Toast.makeText(getApplicationContext(), "Sesión cerrada correctamente", Toast.LENGTH_SHORT);
            toast.show();
            Intent regis = new Intent (ControlApp.this, MainActivity.class);
            startActivity(regis);
            finish();
        }else{
            Toast toast = Toast.makeText(getApplicationContext(), "No se logro cerrar sesion, intentelo de nuevo", Toast.LENGTH_SHORT);
            toast.show();

        }
        break;

    default:
        break;
    }

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}



}

我希望有人可以帮助我找到我的错误,以便我可以纠正错误。谢谢你!!!

4

1 回答 1

2

我猜您正在手动将ListView菜单中 a 的背景颜色设置为黑色,而主要活动主题具有白色背景?

您需要在 上设置android:cacheColorHint属性ListView以匹配列表背景颜色。白色的出现是由于 Android 的渲染优化,它使用该cacheColorHint值在滚动时快速重绘列表。

我曾经读过一篇很好的博客文章,详细介绍了这个问题。我现在找不到它,但如果我找到它会链接到它:)

于 2013-07-09T23:45:29.267 回答