小编ezc*_*odr的帖子

android:从代码中动态更改FAB(浮动操作按钮)图标

如何在运行时更改活动中的FAB图标.我有这个代码 - >

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fabMainActivity);
Run Code Online (Sandbox Code Playgroud)

我知道这是可能的使用,fab.setBackgroundDrawable();但我是Android的新手,不明白该怎么做.

任何帮助将受到高度赞赏.

谢谢

android material-design floating-action-button

41
推荐指数
3
解决办法
4万
查看次数

android-在点击通知上打开默认pdf查看器

我必须根据文件类型/ MIME打开默认应用程序中该文件的下载文件onclick通知.例如 - 如果下载的文件是PDF,则应在PDF查看器中打开,如果下载的文件是图像,则应在图库应用程序等中打开.

我有下面的代码可以正常工作,但是这个代码中使用的一些函数被弃用,如Notification,setLatestEventInfo等.

public void notification(String file, String title, String message){
        NotificationManager nm= (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        Notification n = new Notification(R.drawable.icon,"Download Complete",System.currentTimeMillis());
        Context c= getApplicationContext();
        String text=file+message;

        Intent intent= new Intent();
        intent.setAction(android.content.Intent.ACTION_VIEW);
        File f= new File(Environment.getExternalStorageDirectory()+File.separator+WelcomeActivity.app_files_dir_name+File.separator+file );
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        String ext=f.getName().substring(f.getName().indexOf(".")+1);
        String type = mime.getMimeTypeFromExtension(ext);
        intent.setDataAndType(Uri.fromFile(f), type);
        try {
            PendingIntent i = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
            n.defaults |=Notification.DEFAULT_SOUND;
            n.flags|=Notification.FLAG_AUTO_CANCEL;
            n.setLatestEventInfo(c, title, text, i);
            nm.notify(1, n);
        } catch (android.content.ActivityNotFoundException e) {
            Toast.makeText(MainActivity.this, "File is not …
Run Code Online (Sandbox Code Playgroud)

pdf notifications android

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

在java(android)中使用RegExp来防止其他url除外

我正在创建一个使用webview的应用程序.我只想将我的网站域名页面加载到我的应用程序(webview)中.

如果从我的应用程序中单击某个其他域,则应该要求在其他应用程序(浏览器)中打开.在第一次打击时,我做了以下以防止其他域名 -

@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
                /* url=http://mywebsite.com */
                if(!urlNewString.contains(url)){

                    view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(urlNewString)));
                    return true;
                }
Run Code Online (Sandbox Code Playgroud)

但问题是它还将在浏览器中打开http://blogs.mywebsite.com和所有其他子域,而不是在我的应用程序的webview中.任何人都可以建议我正则表达式来做必要的事情.谢谢.

java regex android webview

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