开发者

Android Dialog, Black text on black background?

开发者 https://www.devze.com 2023-03-20 09:38 出处:网络
I want to set the Background of a ListView in a Dialog to be white and the text black. The following code produces a dialog with black words on a black background. My contextmenu looks correct with bl

I want to set the Background of a ListView in a Dialog to be white and the text black. The following code produces a dialog with black words on a black background. My contextmenu looks correct with black words on white bac开发者_运维问答kground.

        dialog1 = new Dialog(this);         
        AlertDialog.Builder builder = new AlertDialog.Builder(this);            
        builder.setTitle("Select Color Mode");

        ListView modeList = new ListView(this);         
        String[] stringArray = new String[] { "Bright Mode", "Normal Mode" };
        ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, stringArray);
        modeList.setAdapter(modeAdapter);

Am I missing something?

Just to add, I set the theme to Light.


You have to use a custom adapter :

In getView(int position, View v, ViewGroup parent)

You can then call setBackgroundColor() / setBackgroundDrawable() / setBackgroundResource() for each list item


Quick way to change the background color of the listview:

dialog1.getListView().setBackgroundColor(Color.WHITE);
0

精彩评论

暂无评论...
验证码 换一张
取 消