Android:想显示像facebook这样的通知对话框

时间:2014-01-10 06:14:20

标签: android

我想在点击Facebook类型的操作栏中的操作项时显示一个对话框。但是,当对话框出现时,我无法显示如何显示白色箭头(所选操作项目底部的选定项目)。单击操作项时是否为图像替换?请帮忙。

3 个答案:

答案 0 :(得分:3)

 public class WebClient extends WebViewClient
    {
        ProgressDialog pd; // Create Proggress Dialog to show if User Internet connection is slow


        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
            if (!loadingFinished) {
               redirect = true;
            }
        loadingFinished = false;
        view.loadUrl(urlNewString);
        return true;
        }





        public void onPageStarted(WebView view, String url, Bitmap favicon)
        {
            loadingFinished = false;
            try
            {
                if(pd == null){
                    pd = ProgressDialog.show(getParent(), "",Constants.REQUEST_LOADING_STRING, true);
                    pd.setCancelable(false);
                }
            }catch(Exception e)
            {

            }
        }


        @Override
        public void onPageFinished(WebView view, String url) {
            if(!redirect){
               loadingFinished = true;
            }

            if(loadingFinished && !redirect){
              //HIDE LOADING IT HAS FINISHED
                try
                {
                if (pd.isShowing()) {
                    pd.dismiss();
                }
                }catch(Exception e)
                {

                }
            } else{
               redirect = false; 
            }

         }

    }

答案 1 :(得分:0)

试试这个:

CreateNotificationActivity:

public class CreateNotificationActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void createNotification(View view) {
        // Prepare intent which is triggered if the
        // notification is selected
        Intent intent = new Intent(this, NotificationReceiver.class);
        PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);

        // Build notification

        NotificationCompat.Builder noti = new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.fm)
        .setContentTitle("My notification")
        .setContentText("Hello World!")
        .setContentIntent(pIntent); //Required on Gingerbread and below

        noti.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0, noti.build());
getSystemService(NOTIFICATION_SERVICE);
        // hide the notification after its selected





    }
}

NotificationReceiver:

public class NotificationReceiver extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.reciever);
    }

}

答案 2 :(得分:0)

我通过创建一个从PopUpWindow扩展的对话框来解决这个问题。并在操作栏中的操作项下方显示此对话框。因此,当任何一个单击操作栏的项目时,它将与Facebook对话框相同。