0

看法

当我试图在图像上显示时,在我的应用程序中我有一个地址栏、下拉操作菜单和一个 web 视图。

我的问题是;我如何添加描述的 Web 链接,单击时会转到 webview 中的链接?菜单不可更改或添加。

谢谢你。

4

1 回答 1

0

请检查源代码,我认为它对你有帮助。这里 ActionBar.OnNavigationListener Click Event

public class MainActivity extends Activity {

    /** An array of strings to populate dropdown list */
    String[] actions = new String[] {
        "Bookmark",
        "Subscribe",
        "Share"
    };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        /** Create an array adapter to populate dropdownlist */
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_dropdown_item, actions);

        /** Enabling dropdown list navigation for the action bar */
        getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

        /** Defining Navigation listener */
        ActionBar.OnNavigationListener navigationListener = new OnNavigationListener() {

            @Override
            public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                Toast.makeText(getBaseContext(), "You selected : " + actions[itemPosition]  , Toast.LENGTH_SHORT).show();
                return false;
            }
        };

        /** Setting dropdown items and item navigation listener for the actionbar */
        getActionBar().setListNavigationCallbacks(adapter, navigationListener);
    }
}
于 2013-05-14T17:26:56.940 回答