Theme is not applied inside my adapter

Ask by : Waza_Be July 04, 2013 11:30

I am trying to create a simple activity with a ListView (code below)

The Activity is using Theme.Light, but it seems that the simple_list_item_2 is the one for a dark theme.

The result in unreadable text.

Is there a way to use a Light Theme on my ListView?

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_2, array) {
            public View getView(int position, View convertView, ViewGroup parent) {

                TwoLineListItem row;
                if(convertView == null){
                    LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    row = (TwoLineListItem)inflater.inflate(android.R.layout.simple_list_item_2, null);
                    row = (TwoLineListItem)convertView;
                String[] data = this.getItem(position).split(";");
                //No check on data.length for the example.

                return row;

View original question

Answer by : Waza_BeNovember 03, 2012 17:32

Problem solved:

I used:

LayoutInflater inflater = getLayoutInflater();

instead of

LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View original answer