我正在处理的应用程序我已经将主要/暗/重点颜色设置为我想要的颜色,并且它们出现在正确的位置(如预期的那样).我有一个我正在使用的偏好活动,我希望preferenceswitch我使用的颜色会以强调颜色呈现.相反,它们呈现材料蓝绿色.我想知道这是Lollipop的默认行为,就像Kitkat那样是蓝色的吗?我甚至没有引用#009688代码中的任何颜色或我的colors.xml/ styles.xml.
colors.xml
<resources>
<color name="primary">#00BCD4</color>
<color name="primary_dark">#0097A7</color>
<color name="accent">#FFD740</color>
</resources>
Run Code Online (Sandbox Code Playgroud)
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我会提供更多信息.我在这里看到了一些关于创建自定义内容的东西,但这真的有必要吗?
preferenceActivity.java
public class PreferenceActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PrefFrag prefFragment = new PrefFrag();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(android.R.id.content, prefFragment);
fragmentTransaction.commit();
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试确定与变量为 的 Jersey 客户端端点交互的最佳方式Collection<String>。我不是 100% 确定这样做是正确的,但我想知道这是否可能/实现这一目标的正确方法是什么 - 也许@POST带有消息正文?
我的方法DAO是Set<Foo> retrieveByKeys(Collection<String> keys). 因此,我试图找出为此创建端点的最佳方法。第一个想法是:
@POST
@Path('/foos')
@Consumes(MediaType.APPLICATAION_JSON)
@Produces(MediaType.APPLICATAION_JSON)
Response retrieveByKeys(Collection<String> keys) {
... //do things
}
Run Code Online (Sandbox Code Playgroud)
或者:
@GET
@Path('/foos')
Response retrieveByKeys(@QueryParam('keys') Collection<String> keys) {
... //do things
}
Run Code Online (Sandbox Code Playgroud)
我不太确定您是否可以执行第二个操作,但有人建议将其作为可能的解决方案。
无论哪种方式都很好,但同时我的另一种方法DAO是List<Foo> retrievePageStartingFrom(String startKey, int pageSize). 我知道在可能的情况下重用 url 是最佳的休息实践,这就是我试图用这两个做的。我只是在努力寻找一种方法来区分这两种方法,但要保持相同的 url。
我想知道是否有可能用其他方式重载端点,@QueryParams但这次是:
@GET
@Path('/foos')
Response retrievePageStartingFrom(@QueryParam('startKey') String startKey, @QueryParam('pageSize') int pageSize) {
... //do things
}
Run Code Online (Sandbox Code Playgroud)
并且 Jersey 客户端会知道区分这两个调用,因为第一个方法有一个参数,第二个方法有两个也是不同类型的参数。
我想我想我想要做的最好的方法是在 java …
我正在尝试使用它,wavRead(filename)但我收到了消息cannot make a static reference to a non static method.
我可以简单地让它静止,并解决我的问题,但如果不走那条路,怎么办呢.我想保持方法非静态.
这里有一些代码可以让你看到发生了什么:
public class Sound {
double [] mySamples;
public static void main(String[] args){
String filename = null;
System.out.println("Type the filename you wish to act upon.");
Scanner scanIn = new Scanner(System.in);
filename = scanIn.next();
wavRead(filename);
}
public void wavRead(java.lang.String fileName){
mySamples = WavIO.read(fileName);
}
Run Code Online (Sandbox Code Playgroud) 在我的主程序包中,我有两个类和一个包含更多类的文件夹.其中一个外部类是一个单例类,我需要从一堆其他类(在子文件夹中)访问.我可以从同一级别的类中访问单例,因为它没有问题,但是当在其中一个子类中时,它不会让我像其他子一样访问它.我该如何解决这个问题?这里只是一个布局:
com.blah
[Connect]
Ftp.java //I want to be able to say AppConfig.getInstance().blah() in this class
App.java //I can say AppConfig.getInstance().blah() in here just fine
AppConfig.java
Run Code Online (Sandbox Code Playgroud)
编辑这是AppConfig Singleton类的顶部:
class AppConfig {
private static AppConfig config = new AppConfig();
private AppConfig(){}
public static AppConfig getInstance(){
return config;
}
static Properties prop = new Properties();
...
Run Code Online (Sandbox Code Playgroud)
编辑意识到我需要公开面对AppConfig类声明.谢谢提醒伙计.
在我的应用程序中,我有一个编排服务,可以从注册它的不同服务中获取uris.service_1并且service_2可以在不同的机器上,但是一个注册,他们的机器的uris将被存储.
在我的其他应用程序,它利用的是业务流程的服务,我要打电话到业务流程服务来获取URI来使用,但后来我想将它们设置为角常量,或者至少能使用URI的值.
所以这是将使用"常量"的服务,这是从业务流程服务中提取的uri:
(function () {
'use strict';
angular
.module('data.model-view', ['restapi'])
.factory('MVService', MVService);
MVService.$inject = ['$http', '$q', 'exception', 'logger', 'restapi'];
/* @ngInject */
function MVService($http, $q, exception, logger, restapi) {
var HOST = restapi.mvservice.HOST;
var MODULE = restapi.mvservice.MODULE;
...
//below is an example of what will use the above host/module in order to
//get the data needed for this application
function getModels() {
return $http.get(HOST + MODULE + '/model/retrieveAll')
.then(success)
.catch(fail);
function success(response) {
return response.data; …Run Code Online (Sandbox Code Playgroud) computerTotal = (int) Math.ceil(Math.random() * 21);
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何获得16 - 21随机数我在尝试实现Math.floor函数时不断出错...正如你所看到的,我不太擅长将函数放入函数中.
非常感谢!