带有Web链接的下拉操作菜单

时间:2013-05-14 17:14:17

标签: android drop-down-menu webview

view

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

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

谢谢。

1 个答案:

答案 0 :(得分: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);
    }
}