小编rav*_*avz的帖子

尝试在java中出现double $$ charter时拆分字符串

我需要将此字符串拆分为此字符串的任何$$:

String tmpHash = "NA$notValid-1$notValid-2##notValid-3##$$VALID-1##$$VALID-2##$notvalid-4$$VALID-3";
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

String[] arr=tmpHash.split("$$");

        for (int i = 0; i < arr.length; i++) {
            System.out.println("OUTPUT--> "+arr[i]);    

        }
Run Code Online (Sandbox Code Playgroud)

输出是

OUTPUT--> NA$notValid-1$notValid-2##notValid-3##$$VALID-1##$$VALID-2##$notvalid-4$$VALID-3
Run Code Online (Sandbox Code Playgroud)

期望的输出

OUTPUT-->NA$notValid-1$notValid-2##notValid-3##
OUTPUT-->VALID-1##
OUTPUT-->VALID-2##$notvalid-4
OUTPUT-->VALID-3
Run Code Online (Sandbox Code Playgroud)

java regex string android split

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

尝试在AlertDialog上设置标题大小时出现NullPointerException异常

在AlertDialog中,我可以设置Message的大小,但是当我为Title执行相同操作时,它会崩溃.

码:

AlertDialog dialog = new AlertDialog.Builder(this).setMessage(message).setTitle(title)
               .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                      dialog.cancel();
                   }
               }).show();
     TextView titleTxt= (TextView)dialog.findViewById(android.R.id.title);
     **titleTxt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40);** // crash here 
     TextView textView = (TextView) dialog.findViewById(android.R.id.message);
     **textView.setTextSize(40);** // works fine



 Button btn1 = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
   btn1.setTextSize(36); 
Run Code Online (Sandbox Code Playgroud)

我的输出:

05-10 11:49:56.917: E/AndroidRuntime(8376): FATAL EXCEPTION: main
05-10 11:49:56.917: E/AndroidRuntime(8376): java.lang.NullPointerException
05-10 11:49:56.917: E/AndroidRuntime(8376):     at com.binary.taxitop.LoginScreen.showAlertDialog(LoginScreen.java:116)
05-10 11:49:56.917: E/AndroidRuntime(8376):     at com.binary.taxitop.LoginScreen.VerifyCredentialsAndEnterNextScreen(LoginScreen.java:103)
05-10 11:49:56.917: E/AndroidRuntime(8376):     at com.binary.taxitop.LoginScreen.onClick(LoginScreen.java:84)
05-10 11:49:56.917: E/AndroidRuntime(8376):     at android.view.View.performClick(View.java:3511)
05-10 11:49:56.917: E/AndroidRuntime(8376):     at android.view.View$PerformClick.run(View.java:14109)
05-10 …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-alertdialog android-dialog

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