我更新了使用Android Studio 2.2和Gradle 2.2.0.现在我有一个问题.
我按照这篇文章https://medium.com/google-cloud/automatic-per-variant-google-services-json-configurations-with-gradle-d3d3e40abc0e#.g1p7c1tx2配置两个"google-services.json"文件到用于dev vs prod构建,并在我的app/build.gradle文件中使用以下方法在复制两个"google-services.json"文件之间切换.
afterEvaluate {
processDebugGoogleServices.dependsOn switchToDebug
processReleaseGoogleServices.dependsOn switchToRelease
}
task switchToDebug(type: Copy) {
description = 'Switches to DEBUG google-services.json'
from "src/gcm-dev"
include "google-services.json"
into "."
}
task switchToRelease(type: Copy) {
description = 'Switches to RELEASE google-services.json'
from "src/gcm-prod"
include "google-services.json"
into "."
}
Run Code Online (Sandbox Code Playgroud)
Gradle符合要求但是当我点击Android Studio中的"运行应用程序"(三角形"播放"图标)或"调试应用程序"(带有错误的三角形"播放"图标)按钮时,我得到以下内容:
* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'processReleaseGoogleServices' for object of type com.android.build.gradle.AppExtension.
Run Code Online (Sandbox Code Playgroud)
请帮助,非常感谢.
我正在开发一个Android应用程序,我遇到了困难ListActivity.我希望Activity根据单击列表中的哪个项目有一个不同的开始.
我做了一个列表并setListAdapter在java中引用它,但我不知道如何引用它OnListItemClick.我假设我需要引用列表中的位置.
随着Activity和Buttons,我可以设置OnClickListener并使用switch语句和case每一个Button.相当于ListActivity什么?
这是我的代码:
public class Options extends ListActivity implements {
String myHistory[]= { "Item 1", "Item 2", "Item 3" };
//---Set ListView---
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String> ( Options.this,
android.R.layout.simple_list_item_1, myHistory)));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method …Run Code Online (Sandbox Code Playgroud)