小编Rya*_*n R的帖子

顶部和底部带有操作项的Android拆分操作栏?

有没有办法在Split Action Bar的顶部指定一些操作项而其他操作项到底?或者全部或全部,所有行动项目只进入分割的底部?

在此输入图像描述

android android-menu android-actionbar

57
推荐指数
3
解决办法
4万
查看次数

在Android Studio中使用adb over tcpip?

是否有可能以显示adb logcattcpipAndroid Studio中的设备?我正在编写一个使用USB端口的应用程序,我无法使用它adb usb.

目前,我使用以下指令在命令提示符中查看logcat,但如果将它集成到AS中会很好:http: //developer.android.com/tools/help/adb.html#wireless

tcp adb android-studio

55
推荐指数
4
解决办法
7万
查看次数

Google Maps Lite模式会在RecyclerView中导致jank

我有一个RecyclerView垂直滚动的项目列表.每个列表项都包含精简模式下的Google Maps V2 MapView .我正在利用这个新功能返回位图,而不是一个完整的地图作为替代Google Static Maps API.

MapView的需要你打电话onCreate(),onResume(),onPause(),onDestroy()等从父活动/片段的相应的方法.在哪里RecyclerView.Adapter和/或RecyclerView.ViewHolder

如何清理回收的MapView,以便内存不会泄漏,同时保持列表清空?

Google表示精简模式可用于列表:

...'精简模式'地图选项,非常适合您想要提供大量较小地图的情况,或者非常适合有意义的互动不切实际的地图,例如列表中的缩略图.

ListItem.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">

    <com.google.android.gms.maps.MapView
        android:id="@+id/mapImageView"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:layout_width="80dp"
        android:layout_height="100dp"
        map:liteMode="true"
        map:mapType="normal"
        map:cameraZoom="15"/>

<!-- ... -->

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

RecyclerView.Adapter和ViewHolder

public class NearbyStopsAdapter extends RecyclerView.Adapter<NearbyStopsAdapter.ViewHolder> {

    private final Context mContext;

    public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

        MapView map;

        public ViewHolder(View view) {
            super(view);
            map = (MapView) view.findViewById(R.id.mapImageView);
            // Should …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-play-services android-recyclerview google-maps-lite

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

无法找到具有Gradle路径的模块.链接到库 - 未指定

更新2这已在Android Studio 1.2 Beta 3中修复

更新:据报道,这已在即将发布的Android Studio版本中得到修复.

在Android Studio 1.2 Beta 2中,我在同步Gradle时开始收到以下警告.

Failed to set up dependencies
Warning:Unable to find module with Gradle path ':Library1'. Linking to library 'Library1-unspecified' instead.
Warning:Unable to find module with Gradle path ':Library2'. Linking to library 'Library2-unspecified' instead.
Run Code Online (Sandbox Code Playgroud)

我注意到跳转到其中一个库模块中声明的声明会拉出Decompiler,而不是仅仅转到库模块中的实际源.

在我的Android Studio项目中,我有以下模块:

- App
- Library1
- Library2
Run Code Online (Sandbox Code Playgroud)

模块:应用build.gradle代码段:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':Library1')
    compile project(':Library2')
}
Run Code Online (Sandbox Code Playgroud)

settings.gradle 文件:

include ':App'
include ':Library1'
include ':Library2'
project(':Library1').projectDir = new …
Run Code Online (Sandbox Code Playgroud)

android android-studio android-gradle-plugin

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

Android CI使用Bitbucket管道和Docker

我正在尝试在Android的Bitbucket管道中设置持续集成(CI).

我使用Android Studio 2.1.1创建了一个示例空白活动.

使用Pipelines我正在使用uber/android-build-environment Docker容器,它可以很好地创建环境.这是我的bitbucket-pipelines.yml

image: uber/android-build-environment:latest

pipelines:
  default:
    - step:
        script:
          - echo y | android update sdk --filter "extra-android-m2repository" --no-ui -a # Grab the Android Support Repo which isn't included in the container
          - ./gradlew assembleDebug
Run Code Online (Sandbox Code Playgroud)

由于uber/android-build-environment期望像这样运行,因此需要进行一些更改:

docker run -i -v $PWD:/project -t uber/android-build-environment /bin/bash /project/ci/build.sh
Run Code Online (Sandbox Code Playgroud)

例如,源不会复制到卷/project,而是管道将Bitbucket仓库的内容复制到容器的工作目录:

/opt/atlassian/bitbucketci/agent/build
Run Code Online (Sandbox Code Playgroud)

./gradlew assembleDebug运行出现以下错误:

...

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type …
Run Code Online (Sandbox Code Playgroud)

continuous-integration android bitbucket docker bitbucket-pipelines

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

我在哪里将try/catch与"using"语句放在一起?

可能重复:
try/catch + using,正确的语法

我想要try/catch以下内容:

        //write to file
        using (StreamWriter sw = File.AppendText(filePath))
        {
            sw.WriteLine(message);
        }
Run Code Online (Sandbox Code Playgroud)

我把这些try/catch块放在using声明中还是周围?或两者?

c# using-statement try-catch

23
推荐指数
3
解决办法
4万
查看次数

如何使用此WCF联系人将receiveTimeout和sendTimeout设置为无穷大?

我的主机中有以下app.config:

<services>
  <service name="DCC_Service.DCCService" behaviorConfiguration="serviceBehavior">
    <endpoint binding="netNamedPipeBinding" contract="DCC_Service.IDCCService" address="DCCService" />
    <endpoint binding="mexNamedPipeBinding" contract="IMetadataExchange" address="mex" />
    <host>
      <baseAddresses>
        <add baseAddress="net.pipe://localhost/"/>
      </baseAddresses>
    </host>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="serviceBehavior">
      <serviceMetadata httpGetEnabled="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)

如何将netNamedPipeBinding超时设置为无限又名Timespan.MaxValue

wcf wcf-binding

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

使用一个处理程序的WPF切换按钮Checked/Uchecked事件

ToggleButton在WPF窗口中使用a :

 <ToggleButton Height="37"
          HorizontalAlignment="Left"
          Margin="485.738,254.419,0,0"
          VerticalAlignment="Top"
          Width="109"
          IsEnabled="True"
          Checked="toggleAPDTimeoutErr_Checked"
          Unchecked="toggleAPDTimeoutErr_Unchecked">Timeout</ToggleButton>
Run Code Online (Sandbox Code Playgroud)

我有两个正在监视的事件,但这是在处理程序后面的两个不同代码中完成的.怎么能只用一个呢?

我会有很多ToggleButton,代码可以变大.

wpf events togglebutton

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

在Windows 7上使用Jelly Bean 4.1模拟器在ADB中运行systrace工具时出错

如何运行systrace以显示其html输出?在观看Google I/O 2012谈话"For Butter or Worse"后,我无法systrace使用运行Jelly Bean 4.1的模拟器开始使用Windows 7.

我做了以下事情:

  1. 安装了Python 2.7,并将安装文件夹添加到我的PATH中
  2. 冉以下几点:C:\android-sdk\platform-tools\systrace>python systrace.py(与旧的SDK: C:\android-sdk\tools\systrace>python systrace.py)

但我在cmd中收到以下错误:

Traceback (most recent call last):
  File "systrace.py", line 212, in <module>
    main()
  File "systrace.py", line 124, in main
    ready = select.select([adb.stdout, adb.stderr], [], [adb.stdout, adb.stderr])
select.error: (10093, 'Either the application has not called WSAStartup, or WSAStartup failed')
Run Code Online (Sandbox Code Playgroud)

注意:

  • 我在模拟器中启用了跟踪: Settings > Developer Options > Enable traces
  • 我也试过Python 3.2

android adb windows-7 systrace android-4.2-jelly-bean

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

如何在Android上的Retrofit中处理可能是ARRAY或OBJECT的参数?

我遇到的问题是我正在解析的API为大小为1的ARRAY返回一个OBJECT.

例如,有时API会响应:

{
    "monument": [
        {
            "key": 4152,
            "name": "MTS - Corporate Head Office",
            "categories": {},
            "address": {}
        },
        {
            "key": 4151,
            "name": "Canadian Transportation Agency",
            "categories": {},
            "address": {}
        },
        {
            "key": 4153,
            "name": "Bank of Montreal Building",
            "categories": {},
            "address": {}
        }
    ],
}
Run Code Online (Sandbox Code Playgroud)

但是,如果monument数组只有一个项目,它就变成了一个OBJECT(注意缺少[]括号),如下所示:

{
    "monument": {
        "key": 4152,
        "name": "MTS - Corporate Head Office",
        "categories": {},
        "address": {}
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我像这样定义我的模型,只返回一个项目时会出错:

public class Locations {
    public List<Monument> monument;
}
Run Code Online (Sandbox Code Playgroud)

如果只返回一个项目,我会收到以下错误:

Expected BEGIN_OBJECT …
Run Code Online (Sandbox Code Playgroud)

android json retrofit

16
推荐指数
2
解决办法
6340
查看次数