gpt4 book ai didi

java - 当我向下滚动时,侧面菜单变成白色

转载 作者:行者123 更新时间:2023-12-02 06:54:33 25 4
gpt4 key购买 nike

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

/image/asYL9.png

/image/L1gQk.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;
}



}

我希望有人能帮助我发现我的错误,以便我能够纠正错误。谢谢!!!

最佳答案

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

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

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

关于java - 当我向下滚动时,侧面菜单变成白色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17559201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com