小编ozb*_*bek的帖子

为什么split方法不支持$,*etc分隔符来拆分字符串

import java.util.StringTokenizer;
class MySplit
{
  public static void main(String S[])
  {
    String settings = "12312$12121";
    StringTokenizer splitedArray = new StringTokenizer(settings,"$");

    String splitedArray1[] = settings.split("$");
        System.out.println(splitedArray1[0]);

    while(splitedArray.hasMoreElements())
        System.out.println(splitedArray.nextToken().toString());            
  }
}
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,如果我使用分裂字符串$,那么它不能正常工作,如果我与其他符号分裂,那么它工作正常.

为什么要这样,如果它仅支持正则表达式,那么为什么它的做工精细:,,,;等符号.

java regex

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

为什么.bat文件跳过行并跳到最后?

我的.bat文件如下:

@echo on
cd %1\%2
copy D:\source\Meep\bat\ant.properties .\
android update project -p .\ 
ant clean
ant release
Run Code Online (Sandbox Code Playgroud)

当我启动bat文件时,它正确地运行到行android update project -p .\,然后它跳到最后跳过行ant cleanant release.

以下内容在控制台中打印出来:

D:\>cd D:\source\Meep\Meep\trunk\MeepApp

D:\source\Meep\Meep\trunk\MeepApp>copy D:\source\Meep\bat\ant.properties .\
???         1 ????

D:\source\Meep\Meep\trunk\MeepApp>android update project -p .\
Updated local.properties
Updated file D:\source\Meep\Meep\trunk\MeepApp\proguard-project.txt

D:\source\Meep\Meep\trunk\MeepApp>
Run Code Online (Sandbox Code Playgroud)

这是为什么?请告诉我如何运行整个bat命令.非常感谢.

注意:当我逐一在CMD上输入命令时,它运行正常.

java ant android batch-file

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

如何创建隐藏文件夹

我想创建一些隐藏的文件夹,如照片隐藏应用程序和隐藏选定的图像从画廊或相机到选定的隐藏文件夹.我google了很多但我找不到任何解决方案.请找我解决方案..提前谢谢

filesystems android image file sd-card

3
推荐指数
2
解决办法
7405
查看次数

在三星S4中,当我们点击通知时,应用程序无法打开

在我的应用程序中,我向设备发送GCM通知,当我们点击通知时,它不是在三星S4中打开应用程序.请任何人帮助我.

码:

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(icon, message, when);

    Intent notificationIntent = new Intent(context, Main.class);

    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent intent = PendingIntent.getActivity(context, 0,
            notificationIntent, 0);
    String title = context.getString(R.string.app_name);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    notification.defaults |= Notification.DEFAULT_SOUND;

    notification.defaults |= Notification.DEFAULT_VIBRATE;
    notificationManager.notify(0111, notification);
Run Code Online (Sandbox Code Playgroud)

android google-cloud-messaging

2
推荐指数
1
解决办法
687
查看次数

如何在 ImageView 上重叠按钮?

在此处输入图片说明

您好,要获得像上图这样带有附加 reomve 按钮的视图,我尝试了以下 xml Linearlayout 并将其背景设置为圆形图像,但要获得成比例的图片使用 ImageView 会更好,

抱歉,我的英语不太好,但我只是想问我如何通过使用 ImageView 代替 LayoutBackground 来实现这一点...

<LinearLayout
                android:id="@+id/imagePreview"
                android:layout_width="140dp"
                android:layout_height="140dp"
                android:background="@drawable/profile_image_holder"
                android:orientation="vertical"
                android:padding="0dp" >
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <Button
                        android:id="@+id/searchGroupButton"
                        android:layout_width="20dp"
                        android:layout_height="20dp"
                        android:layout_marginLeft="94dp"
                        android:layout_marginTop="5dp"
                        android:background="@drawable/icn_delete"
                        android:onClick="removeImage"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:paddingTop="5dp"
                        android:paddingBottom="0dp"
                        android:textColor="#fff" />
                </LinearLayout>
             </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android

2
推荐指数
1
解决办法
5923
查看次数

在Tizen TV 2016上启用开发者模式[KU6300]

我有三星Tizen TV 2016型号KU6300.根据samsungdforum,可以通过按遥控器上的键12345来启用它.但我有一个模型,只有智能遥控器可用.此遥控器中没有数字键.

智能遥控器

在这台电视上启用开发者模式的步骤是什么?

television tizen

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

如何以排序顺序将新字符添加到现有String?

给出以下字符:"R","G","B"和"X".它们必须一次一个地添加到现有String的长度从0到5不等的长度.这个长度包括特殊字符/.即,现有字符串可能如下所示:

  • null
  • ""(空字符串)
  • "G"
  • "B/X"
  • "G/B"
  • "R/G/B"
  • 等(以上的其他变化)

最终字符串应始终具有"G/R/B/X"的顺序:

  • G 必须是第一项.
  • X 必须是最后一项.
  • R必须在G之前和之后来B.
  • B必须来R.

任何这些字符可能存在也可能不存在.

如果现有字符串只有一个字符,它看起来非常简单:

private String sortThemAll(String existingString, String newString) {
    if (TextUtils.isEmpty(existingString)) {
        return newString;
    }

    if (existingString.length() == 1) {
        List<String> list = Arrays.asList(existingString, newString);
        if (list.contains("G") && list.contains("R")) {
            Collections.sort(list);
        } else {
            Collections.sort(list, Collections.reverseOrder());
        }

        return list.get(0).concat("/").concat(list.get(1));
    }

    if (existingString.length() == 3) { // e.g., "B/X"
        // Assuming that …
Run Code Online (Sandbox Code Playgroud)

java sorting android

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

如何在字符串中的两个或三个逗号后修剪字符串

我有一个字符串

"Domlur, Old Hal Airport Road, Bangalore, Karnataka" 
Run Code Online (Sandbox Code Playgroud)

在这个字符串中我想只存储"Domlur,Old Hal Airport Road"并修剪其余的字符串.

经过一些谷歌研究,我认为我会在这里得到一些帮助.提前致谢.

java string android substring

0
推荐指数
1
解决办法
122
查看次数