小编ant*_*584的帖子

在其他类中获取变量

我需要inString在其他课程中获得变量.我怎样才能做到这一点?

public class main {
    public static StringBuffer inString;


    public static void main(String[] args) {
        inString = new StringBuffer("Our aim is to make a 15 realistic game, where grinding powerlines and doing a tailwhip isn't easy, like in the real world. A game in which you will feel like you're actual riding. A game in which creativity and beauty are combined. ");
        inString = new StringBuffer(inString.toString().replaceAll(" +", " "));
        }
}
Run Code Online (Sandbox Code Playgroud)

所以我尝试System.out.println(main.inString);在我的Textcl.class中使用,但得到null.

java class

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

String Array中的indexOf错误

我想用第二个char对String数组进行排序,但位置"1"的char索引始终为-1,因此sort不起作用.怎么了?

String[] wordList = outString.toString().split(", ");

for (int i = 0; i < wordList.length; i++) {
    int n =wordList[i].indexOf(wordList.toString().charAt(1));
}

Arrays.sort(wordList, 1,0);

for (String str : wordList) {
    System.out.println(str);
}
Run Code Online (Sandbox Code Playgroud)

java arrays sorting string

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

Kotlin 应用于 String 时未按预期工作

我正在尝试使用 kotlin 的所有功能,但似乎它们都不起作用,或者可能是我的错。

所以,applyString工作。例子:

val str = someStr.apply {
    toUpperCase()
    if (contains("W")) replace("W", "w")
}
Run Code Online (Sandbox Code Playgroud)

输入 -> xywz

输出 -> xywz

预期 -> XYwZ

Java风格:

val str = it.text().toString().toUpperCase()
if (str.contains("W")) str.replace("W", "w")
Run Code Online (Sandbox Code Playgroud)

输入 -> xywz

输出 -> XYwZ

预期 -> XYwZ

难道我做错了什么?

android syntactic-sugar kotlin

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

Android Google Map Cluster 图标忽略自定义图标

Android Google 地图集群图标在缩小时忽略自定义图标。有什么建议如何修复它吗?

override fun onBeforeClusterRendered(cluster: Cluster<T>, markerOptions: MarkerOptions) {
    mClusterIconGenerator.setBackground(context?.let { ContextCompat.getDrawable(it, R.drawable.map_cluster_item) })
    mClusterIconGenerator.setTextAppearance(R.style.WhiteTextAppearance)
    val icon = mClusterIconGenerator.makeIcon(cluster.size.toString())
    markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 在此输入图像描述

android google-maps google-maps-markers

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