小编L.M*_*eng的帖子

任务':bintrayUpload'的执行失败.

我想将我的库上传到jecenter.我创建了bintray帐户等,并按照此处提到的所有步骤进行操作.

我在应用程序模块和库模块中进行了以下更改.

//库build.gradle

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    resourcePrefix "winchance"

    version = "1.0.0"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName version
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.code.gson:gson:2.2.4'
}

def siteUrl = "https://github.com/lubeast/WinchanceHttpUtil"
def gitUrl = "https://github.com/lubeast/WinchanceHttpUtil.git"

group = "com.winchance.library"

install {
    repositories.mavenInstaller { …
Run Code Online (Sandbox Code Playgroud)

android maven jcenter

7
推荐指数
1
解决办法
2200
查看次数

AlertDialog更改正按钮颜色

在此输入图像描述

我想改变正面按钮的颜色Alertdialog,这是我在下面做的:

// style.xml

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:buttonBarPositiveButtonStyle">@style/positive</item>
</style>

<style name="positive">
    <item name="android:textColor">@color/accent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我使用的风格是:

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AlertDialogCustom);
Run Code Online (Sandbox Code Playgroud)

但我正在做的不起作用,我只是想改变正面的按钮颜色.我不想在java代码中更改按钮的颜色.

提前致谢 :-)

Edit-1 Alertdialog布局xml

<android.support.v7.internal.widget.ButtonBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/buttonPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="locale"
android:orientation="horizontal"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:gravity="bottom"
app:allowStacking="@bool/abc_allow_stacked_button_bar"
style="?attr/buttonBarStyle">

<Button
    android:id="@android:id/button3"
    style="?attr/buttonBarNeutralButtonStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<android.support.v4.widget.Space
    android:id="@+id/spacer"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:visibility="invisible" />

<Button
    android:id="@android:id/button2"
    style="?attr/buttonBarNegativeButtonStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<Button
    android:id="@android:id/button1"
    style="?attr/buttonBarPositiveButtonStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

android material android-alertdialog

5
推荐指数
3
解决办法
1万
查看次数

带有DrawerLayout setCheckedItem的NavigationView不起作用

我想NavigationView在应用启动时检查一项。但是我发现NavigationView.setCheckedItem(R.id.xxx)没有工作。我也尝试过navigationView.getMenu().findItem(R.id.xxx).setChecked(true),同样的结果。

我已经将checkableBehavior设置为single。

<item android:title="@string/sliding_menu_group_places">
        <menu>
            <group android:checkableBehavior="single">
                <item
                    android:id="@+id/xxx"
                    android:icon="@drawable/xxx"
                    android:title="@string/xxx" />

                <item
                    android:id="@+id/xxx"
                    android:icon="@drawable/xxx"
                    android:title="@string/xxx" />

                ...
            </group>
        </menu>
    </item>
Run Code Online (Sandbox Code Playgroud)

但是有一种方法可以工作:

drawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            navigationView.setChecked(R.id.xxx);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
        }

        @Override
        public void onDrawerStateChanged(int newState) {
        }
    });
Run Code Online (Sandbox Code Playgroud)

导航项将在onDrawerOpened回调中进行检查。我在stackoverflow中进行了大量搜索,但没有一种方法适合我。谁能帮我这个忙。

编辑1

<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)

<group android:checkableBehavior="single">
    <item
        android:id="@+id/xxx"
        android:icon="@drawable/xxx"
        android:title="@string/recent_display_name" />

    <item android:title="@string/sliding_menu_group_places">
        <menu>
            <group android:checkableBehavior="single"> …
Run Code Online (Sandbox Code Playgroud)

android drawerlayout android-navigationview

3
推荐指数
1
解决办法
1830
查看次数