小编cri*_*007的帖子

Android Studio - 如何在单个窗口中打开多个项目?

我已下载Android Studio并开始将其用于我的Android开发.

我需要知道,如何在像Eclipse这样的单一窗口中打开多个项目.期待一些帮助,谢谢.

trouble-tickets android-studio

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

Lollipop的backgroundTint对Button没有影响

我的活动中有一个Button,我希望它有我主题的强调色.而不是像我们必须做的那样制作我自己的可绘制的Lollipop,我自然会想要使用新backgroundTint属性.

<Button
    android:id="@+id/btnAddCode"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:backgroundTint="@color/accent"
    android:text="@string/addressInfo_edit_addCode" />
Run Code Online (Sandbox Code Playgroud)

不幸的是它没有效果,按钮保持灰色.

我尝试了不同的值backgroundTintMode,但没有改变任何东西.

我也尝试在我的Activity中以编程方式进行,它没有改变任何东西.

addCodeView.findViewById(R.id.btnAddCode).setBackgroundTintList(
     getResources().getColorStateList(R.color.accent));
Run Code Online (Sandbox Code Playgroud)

为什么我的色彩被忽略了?

编辑:只是为了澄清,我确实在Lollipop设备上进行测试.其他小部件(例如EditText)正确并自动着色.

android tint android-layout

79
推荐指数
8
解决办法
7万
查看次数

从片段开始活动

我有2个片段,两个片段都有一个按钮.当我按下按钮时,我想开始一个新的活动.但我无法让它发挥作用.

我得到的错误:ERROR here:类型不匹配:无法从mFragmentFavorite转换为Fragment

我究竟做错了什么?

MyFragmentPagerAdapter

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class MyFragmentPagerAdapter extends FragmentPagerAdapter{

    final int PAGE_COUNT = 3;

    /** Constructor of the class */
    public MyFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    /** This method will be invoked when a page is requested to create */
    @Override
    public Fragment getItem(int arg0) {

        switch(arg0){

        case 0:
            return new FavoriteActivity();
                    //ERROR: Type mismatch: cannot convert from FavoriteActivity to Fragment


        case 1:
            return new SettingsActivity();


        default:
            return null;

        }       
    }

    /** …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-activity android-fragmentactivity

77
推荐指数
3
解决办法
22万
查看次数

AttributeError:模块“集合”没有属性“MutableMapping”

/usr/bin/python3我最近在我的 ubuntu 系统上安装了 python3.10,我相信我从到建立了一个链接/usr/bin/python3.10

如果我跑步,python --version我会得到Python 2.7.17,如果我跑步,python3 --version我会得到Python 3.10.2

我相信我所做的事情破坏了我的全局 python / pip 中的某些内容。

每当我尝试全局使用 pip 时,都会收到此错误:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal.cli.main import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 73, in <module>
    vendored("pkg_resources")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 77, in <module>
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module> …
Run Code Online (Sandbox Code Playgroud)

python pip python-3.x

77
推荐指数
6
解决办法
16万
查看次数

如何使用Gson解析JSON数组

我想解析JSON数组并使用gson.首先,我可以记录JSON输出,服务器明确地响应客户端.

这是我的JSON输出:

 [
      {
           id : '1',
           title: 'sample title',
           ....
      },
      {
           id : '2',
           title: 'sample title',
           ....
     },
      ...
 ]
Run Code Online (Sandbox Code Playgroud)

我试过这个结构进行解析.一个类,它依赖于单个arrayArrayList所有JSONArray.

 public class PostEntity {

      private ArrayList<Post> postList = new ArrayList<Post>();

      public List<Post> getPostList() { 
           return postList; 
      }

      public void setPostList(List<Post> postList) { 
           this.postList = (ArrayList<Post>)postList; 
      } 
 }
Run Code Online (Sandbox Code Playgroud)

发布课程:

 public class Post {

      private String id;
      private String title;

      /* getters & setters */
 }
Run Code Online (Sandbox Code Playgroud)

当我尝试使用gson没有错误,没有警告和没有日志:

 GsonBuilder gsonb = new GsonBuilder();
 Gson gson …
Run Code Online (Sandbox Code Playgroud)

java arrays android json gson

73
推荐指数
3
解决办法
10万
查看次数

所有com.android.support库必须使用完全相同的版本

当我今天将我的android工作室从版本2.2.3更新到2.3时,突然在我的build.gradle中在依赖项的第一个编译行中出现此错误

(无论哪个依赖都会出现在第一位,但它总会给我这个错误):

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).找到的版本25.2.0,24.0.0.示例包括com.android.support:animated-vector-drawable:25.2.0和com.android.support:mediarouter-v7:24.0.0

我查看了我的整个项目,我找不到任何版本的24.0.0(我用ctrl + shift + F来查找整个项目)

这是我的build.gradle:

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionName "1.0"
        versionCode 1
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            minifyEnabled true
            shrinkResources true
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.squareup:otto:1.3.8'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:multidex:1.0.1'
}
Run Code Online (Sandbox Code Playgroud)

android gradle

69
推荐指数
6
解决办法
5万
查看次数

如何在apache kafka中删除主题

我需要删除kafka-0.8.2.2.3中的主题.我使用以下命令删除主题:

bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic DummyTopic
Run Code Online (Sandbox Code Playgroud)

该命令执行成功,但是当我运行命令列出主题时,我可以看到该主题仍然存在,并显示标记为删除.

bin/kafka-topics.sh --list --zookeeper localhost:2181
DummyTopic - marked for deletion
Run Code Online (Sandbox Code Playgroud)

当我创建DummyTopic主题时,它会输出异常,主题已经存在,下面是堆栈跟踪:

Error while executing topic command Topic "DummyTopic" already exists.
kafka.common.TopicExistsException: Topic "DummyTopic" already exists.
    at kafka.admin.AdminUtils$.createOrUpdateTopicPartitionAssignmentPathInZK(AdminUtils.scala:248)
    at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:233)
    at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:92)
    at kafka.admin.TopicCommand$.main(TopicCommand.scala:54)
    at kafka.admin.TopicCommand.main(TopicCommand.scala)
Run Code Online (Sandbox Code Playgroud)

请让我知道如何删除此主题.

java apache-kafka

67
推荐指数
1
解决办法
11万
查看次数

github-actions[bot] 权限被拒绝

我正在使用 mkdocs 为我的项目生成文档,现在我无法将这些文档部署到 Github 页面,它告诉我:

远程:github-actions[bot] 对 XXX.git 的权限被拒绝。致命:无法访问“XXX”:请求的 URL 返回错误:403

这是我的CI配置

还有我的存储库秘密:(这两个GIT_ACTIONS_PUSH都是我个人的访问令牌。)

如果我CI手动启动该过程,将会像这样CI崩溃。

我该如何解决?

github-api github-actions

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

Android Studio build.gradle警告消息

在我成功更新到Android Studio 3.1 Canary 9之后,我收到了警告消息

Warning:Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018
Run Code Online (Sandbox Code Playgroud)

我知道这个警告不会在我的项目中造成任何问题,至少目前是这样.但我想完全删除它,以便将来不会有任何问题.但在查看我的build.gradle文件后,我找不到任何已调用此警告的代码行.

这是我的build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "app.project.virtualdiary"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation …
Run Code Online (Sandbox Code Playgroud)

android android-studio android-gradle-plugin

63
推荐指数
4
解决办法
5万
查看次数

未安装Linter pylint

我想在Microsoft Visual Studio Code中运行python代码,但它给出了一个错误:

"没有安装Linter pylint"

我安装了:

  • VS Code Python扩展
  • Python3
  • 蟒蛇

我该如何安装pylint?

python pylint visual-studio-code

62
推荐指数
5
解决办法
9万
查看次数