2013-07-09 40 views
0

我想在我的應用程序中實現一個側面菜單,它在大多數情況下都能正常工作,但是我遇到的問題是,一旦顯示de菜單並嘗試向下滾動整個列表變成白色(背景),文字消失。當我滾動dow時,側面菜單變成白色

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; 
} 



} 

我希望有人能幫助我找到我的錯誤,所以我可以糾正錯誤。謝謝!!!

回答

2

我猜你是手動將菜單中的ListView的背景顏色設置爲黑色,而主要活動主題有白色背景?

您需要設置ListView上的android:cacheColorHint屬性以匹配列表背景顏色。白色由於Android渲染優化而出現,它使用cacheColorHint值在滾動時快速重繪列表。

我讀過一篇很好的博客文章,詳細介紹了這個問題。我現在找不到它,但會鏈接到它,如果我這樣做:)

+1

不用擔心,你的答案解決了我的問題,你不妨是一個天使......誰知道!謝謝!! –

相關問題