Java 当我滚动dow时,侧菜单变为白色
我正在尝试在我的应用程序中实现一个侧菜单,它在大多数情况下工作正常,但我遇到的问题是,一旦我显示de menu并尝试向下滚动,整个列表将变为白色(背景),文本将消失 上面我附上了两张显示菜单行为的图片,当我将手指从左向右滑动时,侧菜单显示,但如果我在菜单中向下滚动,它将变成一个空的白色列表,下面是我的代码:Java 当我滚动dow时,侧菜单变为白色,java,android,eclipse,Java,Android,Eclipse,我正在尝试在我的应用程序中实现一个侧菜单,它在大多数情况下工作正常,但我遇到的问题是,一旦我显示de menu并尝试向下滚动,整个列表将变为白色(背景),文本将消失 上面我附上了两张显示菜单行为的图片,当我将手指从左向右滑动时,侧菜单显示,但如果我在菜单中向下滚动,它将变成一个空的白色列表,下面是我的代码: public class ControlApp extends SlidingActivity{ ArrayList<String> datos ; ArrayAdapte
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;
}
}
公共类ControlApp扩展了SlidengActivity{
数组列表datos;
ArrayAdapter适配器;
意图;
私有字符串[]mMenuLista;
//私人MyCustomAdapter mAdapter;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notifications);
setBehindContentView(R.layout.activity_菜单);
初始化(这是“BqCCNsbb14MPgeWz3rznxO4DamuXUbsgiTug8P8I”,“9j7gslwnv46fkpsnmwnmd2formalicklgitfdq2b”);
trackapponed(getIntent());
getSlidingMenu().SetbehinOffset(100);
//mAdapter=新的MyCustomAdapter();
setDefaultPushCallback(this,notificacions.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
mMenuLista=getResources().getStringArray(R.array.lista_菜单);
//对于(int i=0;i我猜您是在手动将菜单中的列表视图的背景色设置为黑色,而主活动主题有白色背景
您需要在ListView
上设置android:cacheColorHint
属性以匹配列表背景色。由于android使用该cacheColorHint
值在滚动时快速重新绘制列表,因此出现白色
我曾经读过一篇很好的博客文章,详细介绍了这个问题。我现在找不到,但如果我找到了,我会链接到它:)不用担心,你的回答解决了我的问题,你还不如做个天使……谁知道呢!!!谢谢!!