app:showAsAction 和android:showAsAction

來源:互聯網
上載者:User

標籤:

app:showAsAction

它有三個可選項
1.always:總是顯示在介面上
2.never:不顯示在介面上,只讓出現在右邊的三個點中
3.ifRoom:如果有位置才顯示,不然就出現在右邊的三個點中

 

 

android:showAsAction

這個屬性可接受的值有:

1.alaways:這個值會使功能表項目一直顯示在ActionBar上。

2.ifRoom:如果有足夠的空間,這個值會使菜單顯示在ActionBar上。

3.never:這個值菜單永遠不會出現在ActionBar是。

4.withText:這個值使菜單和它的表徵圖,菜單文本一起顯示。

 

When using the appcompat library, menu resources should refer to the showAsAction in the app: namespace, not the android: namespace.Similarly, when not using the appcompat library, you should be using the android:showAsAction attribute.
I think the problem is that you are mixing Framework Activity and AppCompat menu.You should use AppCompatActivity with AppCompat Action bar and app:showAsAction;
or Activity with android:showAsAction.
public class MainActivity extends AppCompatActivity {//像這樣的AppCompatActivity 需要使用app:showAsAction    ..........  }

 

public class MainActivity extends Activity{ //像這樣的Activity 需要使用android:showAsAction      .........  }

 

app:showAsAction 和android:showAsAction

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.