小编Nil*_*bja的帖子

Android marshmallow请求权限?

我目前正在开发一个需要几个"危险"权限的应用程序.因此,我尝试在Android Marshmallow(API级别23)中添加"请求许可",但无法找到如何执行此操作.

如何在我的应用中使用新的权限模型请求权限?

android android-permissions android-6.0-marshmallow

151
推荐指数
8
解决办法
24万
查看次数

invokedynamic需要--min-sdk-version> = 26

今天下载了工作室3.0 beta 2.0版本,之后尝试在其中打开现有项目并遇到一些困难,其中大多数我可以借助Google和Stack Overflow解决,但这个我不能.

Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: org.gradle.tooling.BuildException: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Run Code Online (Sandbox Code Playgroud)

还发布我的应用程序gradle

apply plugin: 'com.android.application'
   android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

defaultConfig {
    applicationId "com.intersoft.snappy"
    minSdkVersion 19
    targetSdkVersion 22
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
}
buildTypeMatching 'dev', 'debug'
buildTypeMatching 'qa', 'debug'
buildTypeMatching 'rc', 'release'
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] 
} }
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt' …
Run Code Online (Sandbox Code Playgroud)

android android-studio build.gradle android-gradle-plugin

42
推荐指数
4
解决办法
2万
查看次数

关于滚动值的Recyclerview从适配器更改

我正在开发一个应用程序,我正在尝试使用RecyclerView和recycler适配器填充列表.但是当我快速滚动列表时,有时列表项中的值会在列表项之间进行洗牌.这有一个已知的解决方案吗?

android recycler-adapter android-recyclerview

15
推荐指数
4
解决办法
8684
查看次数

选项菜单不显示文本

我用这段代码创建了我的菜单:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@+id/donate" 
        android:icon="@drawable/donate" 
        android:title="Donate"/>

    <item android:title="@string/color_picker" 
        android:id="@+id/color_picker" 
        android:icon="@drawable/colorpicker"/>
</menu>
Run Code Online (Sandbox Code Playgroud)

当我点击菜单按钮时,图像出现但文本没有.我正试图让文字显示出来,据我所知,文字应该出现......我做错了什么?

android

9
推荐指数
1
解决办法
4338
查看次数

在折叠工具栏布局中添加FloatingActionButton

目前正在开发应用程序,我需要在其右下角添加"共享"和"添加"按钮Collapsing toolbar(用于视差效果).

这可能隐藏在滚动或可能坐在上面Actionbar.添加了我想要实现的图像.目前还不知道如何做到这一点(尝试使用锚点的浮动操作按钮,但失败了).

这应该是这样的:

这是代码:

 <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/htab_maincontent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/htab_appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/htab_collapse_toolbar"
        android:layout_width="match_parent"
        android:layout_height="256dp"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

        <ImageView
            android:id="@+id/htab_header"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/header"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            app:layout_collapseMode="parallax"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/htab_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:gravity="top"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:titleMarginTop="13dp"/>
    </android.support.design.widget.CollapsingToolbarLayout>

    <android.support.design.widget.TabLayout
        android:id="@+id/htab_tabs"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="bottom"
        android:background="@color/colorPrimary"
        app:tabIndicatorHeight="@dimen/tabIndicatorHeight"/>
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/htab_viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

android material-design floating-action-button android-collapsingtoolbarlayout

6
推荐指数
1
解决办法
6647
查看次数

如何在“ wdullaer materialdatetimepicker”中设置自定义的最小和最大日期选择日期

我正在一个项目中,我需要限制用户选择我想要的其他日期。

通过阅读一些文章和SO帖子,我尝试了以下应该起作用的方法

    com.wdullaer.materialdatetimepicker.date.DatePickerDialog dpd = newInstance(
                ActivityClaimOffers.this,
                now.get(Calendar.YEAR),
                now.get(Calendar.MONTH),
                now.get(Calendar.DAY_OF_MONTH)
        );
    dpd.setMinDate(calendar);
    dpd.setMaxDate(calendar);
Run Code Online (Sandbox Code Playgroud)

但我不知道如何将自定义日期作为日历对象传递。因为setMinDate()和setMaxDate()都将Calendar作为参数

android datetimepicker custom-datetimepicker android-studio

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

删除由Glide设置的图像,并使用imageView.setImageBitmap()

我有一个片段,其中首先使用Glide(从互联网获取的图像网址)将Image设置为imageView。然后,在图像视图上单击时,可以从图库或相机意图中选择新图像。问题是当我尝试设置从OnActivityResult()获取的位图时。图像实际已设置,但被滑行重叠。我需要显示从相机/画廊捕获的图像。感谢您提供任何帮助,如果可以使用Picasso或任何其他库来完成,请提出建议。以下是我到目前为止尝试过的

onActivityResult()

 @Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK)
    {
        if (requestCode == SELECT_FILE)
            onSelectFromGalleryResult(data);
        else if (requestCode == REQUEST_CAMERA)
            //   onCaptureImageResult((Bitmap) data.getExtras().get("data"));
            onCaptureImageResult(data);
    }
}

private void onCaptureImageResult(Intent data)
{
    if (data != null)
    {
        mImageUri = Uri.parse("file://" + data.getStringExtra(CameraConfiguration.Arguments.FILE_PATH));
    }

    try
    {
        bitmap_image = MediaStore.Images.Media.getBitmap(mContext.getContentResolver(), mImageUri);
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        bitmap_image.compress(Bitmap.CompressFormat.JPEG, 60, bytes);

        bitmap_image = Bitmap.createScaledBitmap(bitmap_image, (int) (bitmap_image.getWidth() * 0.5), (int) (bitmap_image.getHeight() * 0.5), true);

        ExifInterface ei …
Run Code Online (Sandbox Code Playgroud)

android imageview android-imageview android-glide

5
推荐指数
2
解决办法
1722
查看次数

无法解析com.commonsware.cwac:camera:0.6.+

我在我的应用程序中添加了tedpicker来自https://github.com/ParkSangGwon/TedPicker

但是现在几个星期,当我尝试将gradle与互联网同步时,会出现此错误

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
> Could not resolve com.commonsware.cwac:camera:0.6.+.
Required by: YourApp:app:unspecified > com.github.ParkSangGwon:TedPicker:v1.0.10
> Could not resolve com.commonsware.cwac:camera:0.6.+.
> Failed to list versions for com.commonsware.cwac:camera.
> Unable to load Maven meta-data from https://repo.commonsware.com.s3.amazonaws.com/com/commonsware/cwac/camera/maven-metadata.xml.
> Could not GET https://repo.commonsware.com.s3.amazonaws.com/com/commonsware/cwac/camera/maven-metadata.xml'.
> Host name 'repo.commonsware.com.s3.amazonaws.com' does not match the certificate subject provided by the peer (CN=*.s3.amazonaws.com, O=Amazon.com Inc., L=Seattle, ST=Washington, C=US)
Run Code Online (Sandbox Code Playgroud)

但如果我在gradle中切换到离线模式,它可以正常工作

这也是我的应用程序的buid.gradle

buildscript {
repositories {
    mavenCentral() …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-gradle-plugin

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

设计日期选择器,如在Android L中的时钟中找到

结果我想实现

我正在开发一个应用程序,我想把日期选择器放在下面(我在android L的时钟应用程序中看到).谁知道如何实现它?或者是否存在实施此项目的图书馆或项目?

android material-design android-5.0-lollipop

0
推荐指数
1
解决办法
319
查看次数