Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright 2012-present Pixate, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

import android.content.res.ColorStateList;
import android.graphics.Color;

public class Main {
    /**
     * Creates a color states-list.
     * 
     * @param color
     * @return A state-list
     */
    public static ColorStateList createColorStateList(int color) {
        // @formatter:off
        // FIXME - This is buggy. The minute we set the color in, the button is no longer clickable....
        //   [[-16842910], [16842908, -16842910], [16842919], [16842913], [16842908], []]
        //  [-2147483648,      -2147483648,          -1,         -1,        -1,   -16777216]
        return new ColorStateList(
                new int[][] { new int[] { -android.R.attr.state_enabled },
                        new int[] { android.R.attr.state_focused, -android.R.attr.state_enabled },
                        new int[] { android.R.attr.state_pressed }, new int[] { android.R.attr.state_selected },
                        new int[] { android.R.attr.state_focused }, new int[0] },
                new int[] { Integer.MIN_VALUE, // !enabled
                        Integer.MIN_VALUE, // focused & !enabled
                        Color.WHITE, // pressed
                        Color.WHITE, // selected
                        Color.WHITE, // focused
                        color });

        // @formatter:on
    }
}