1

我在 mapview https://github.com/johannilsson/android-actionbar中将此库用于操作栏,我想在按钮单击操作栏中的项目时显示我的位置,但我不知道该怎么做我挣扎了好几个小时......这是我的代码:

ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);

        actionBar.setTitle("Home");
        actionBar.setHomeAction(new IntentAction(this, Main.createIntent(this), R.drawable.ic_title_home_default));

                actionBar.addAction(new locationAction());


                // add a listener to the title

                actionBar.setOnTitleClickListener(new OnClickListener() {
        @Override   
       public void onClick(View v) {

         makeToast("Title clicked...");
                    }

                });
    }

        // the location action should go here

        private class locationAction implements Action {

            @Override

            public int getDrawable() {

                return R.drawable.location;
            } 


            @Override

            public void performAction(View view) {

                makeToast("Refreshing...");
}
}

     // a simple method to create an intent

        public static Intent createIntent(Context context) {

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

            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

            return i;

        }

        public void makeToast(String message) {

            Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

        }       }

请帮忙!

4

0 回答 0