Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Lập trình Android: tạo MenuOptions ppsx
MIỄN PHÍ
Số trang
4
Kích thước
107.0 KB
Định dạng
PDF
Lượt xem
1945

Tài liệu đang bị lỗi

File tài liệu này hiện đang bị hỏng, chúng tôi đang cố gắng khắc phục.

Lập trình Android: tạo MenuOptions ppsx

Nội dung xem thử

Mô tả chi tiết

Trung tâm Tin học – ĐH KHTN

Tạo “MenuOptions”

Sau đây mình sẽ tạo 1 demo nho nhỏ để giới thiệu cho các bạn về phần SubMenu:

Đầu tiên các bạn tạo 1 Project như sau:

Project name: MySubMenu

Build Target: Android 1.6

Application name: MySubMenu

Package name: org.example.MySubMenu

Create Activity: MySubMenu

Sau đó các bạn tạo 1 folder Menu và thêm vào 1 file menu.xml với nội dung:

<?xml version="1.0" encoding="UTF-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@+id/Menu1" android:orderInCategory="1"

android:title="Add" />

<item android:id="@+id/submenu" android:title="Send"

android:orderInCategory="2">

<menu>

<item android:id="@+id/submenu1" android:title="Via

BlueTooth" />

<item android:id="@+id/submenu2" android:title="Via SMS" />

</menu>

</item>

<item android:id="@+id/Menu3" android:orderInCategory="3"

android:title="Copy" />

<item android:id="@+id/Menu4" android:title="Delete"

android:orderInCategory="4" />

</menu>

Sau đó các bạn chỉnh sửa file MySubMenu.java như sau:

package org.example.MySubMenu;

import android.app.Activity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuInflater;

import android.view.MenuItem;

import android.widget.Toast;

public class MySubMenu extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

Lập trình Android – http://laptrinhdidong.vn Page 1

Tải ngay đi em, còn do dự, trời tối mất!