【问题标题】:Notification bar without any buttons没有任何按钮的通知栏
【发布时间】:2014-08-12 12:38:01
【问题描述】:

我想向用户发送一些通知,但我不想向用户显示设置按钮和其他通知等标准项目。我的意思是我需要一个空的通知栏。有没有办法创建一个空的通知栏?

【问题讨论】:

  • Android 中没有“通知栏”之类的东西。从技术上讲,它是显示通知的状态栏。回答你的问题 - 不,你不能这样做。尽管可以在您的活动运行时隐藏/删除状态栏,但是当用户离开您的活动(并且状态栏重新出现)时,任何通知仍然可用,并且在此之前用户将无法访问它们。您必须在应用中创建自己的通知系统,并在使用时隐藏状态栏。
  • 感谢您的建议,但我不知道创建自己的通知系统的最佳方法是什么?我应该使用哪个安卓控件?按钮?文本视图?

标签: android push-notification android-notifications android-notification-bar


【解决方案1】:

发布到目前为止的代码总是很有帮助的。我知道,如果您不提供图标,则通知将不会显示,除非您将其标记为“PRIORITY_LOW”。

Here 是一个包含更多信息的帖子,可能会对您有所帮助!

【讨论】:

    【解决方案2】:
       **JS**
    

    函数错误(消息){

    $('<div/>').prependTo('body').addClass('notify-error').html(msg).slideDown();
    

    }

    函数成功(msg){

    $('<div/>').prependTo('body').addClass('notify-success').html(msg).slideDown();
    

    }

    $('#notify-error').click(function () {
    
        $(this).slideUp().empty();
    
    });
    
    $('#notify-success').click(function () {
    
        $(this).slideUp().empty();
    
    
    });   
    

    error('错误!');

    成功('成功!');

    【讨论】:

      【解决方案3】:

      .CSS

      .notify-success {
      
          position:relative;
      
          width:100%;
      
          background-color:green;
      
          height:30px;
      
          color:white;
      
          display:none;
      
          text-align:center;
      
          padding:5px;
      
          font-size:2em;
      
          line-height:1em;
      
          font-family: Arial, sans-serif;
      
          border:2px solid #666;
      
          cursor:pointer;
      }
      
       .notify-error {
          position:relative;
      
          width:100%;
      
          background-color:red;
      
          height:30px;
      
          color:white;
      
          display:none;
      
          text-align:center;
      
          padding:5px;
      
          font-size:2em;
      
          line-height:1em;
      
          font-family: Arial, sans-serif;
      
          border:2px solid #666;
      
          cursor:pointer;
       }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-10
        • 2015-10-07
        • 1970-01-01
        相关资源
        最近更新 更多