2017-03-15 62 views
-1

我厭倦了一些代碼,但我無法修復它。我manu.xml我如何可以在textview中獲得一個weblink - Android

<menu xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
tools:context=".MainActivity"> 
<item 
    android:id="@+id/action_settings" 
    android:orderInCategory="100" 
    android:title="@string/action_feedback" 
    app:showAsAction="never" /> 

我怎樣才能在這個XML網絡鏈接?非常感謝。

+0

_I累一些代碼。 .._你究竟試過了什麼? –

+0

你想在菜單項被點擊時啓動瀏覽器嗎? –

+0

我會在那裏放一個遊戲商店的鏈接。 Web瀏覽器或Plah Store應用程序無關緊要。 –

回答

0

示例將ContextMenu

第一個覆蓋onCreateContextMenu:

@Override 
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { 
    super.onCreateContextMenu(menu, v, menuInfo); 
    MenuInflater inflater = getMenuInflater(); 
    inflater.inflate(/*your menu id*/, menu); 
} 

然後覆蓋onContextItemSelected開放網頁視圖或Play商店應用:

@Override 
    public boolean onContextItemSelected(MenuItem item) { 
     AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); 
     switch (item.getItemId()){ 
      case action_settings: { 
       //your code 
       return true; 
      } 
      default: 
       return super.onContextItemSelected(item); 
     } 
    } 
相關問題