編輯:關於Android編程
本文實例講述了Android創建Menu菜單的方法。分享給大家供大家參考。具體方法如下:
復制代碼 代碼如下:package com.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
public class TestandroidActivity extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId())
{
case R.id.settings:
startActivity(new Intent(this,com.test.Settings.class));
return true;
}
return false;
}
}
復制代碼 代碼如下:package com.test;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class Settings extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
}
}
相關配置文件如下:
復制代碼 代碼如下:<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference android:key="music" android:summary="@string/music_summary" android:defaultValue="true" android:title="@string/music_title"/>
<CheckBoxPreference android:key="hints" android:summary="@string/hints_summary" android:title="@string/hints_title"/>
</PreferenceScreen>
希望本文所述對大家的Android程序設計有所幫助。
linux 主機 android sdk安裝忽略jdk安裝忽略hudson安裝忽略 gradle安裝1:下載對應的gradle(這裡是gradle-2
android之利用surfaceView實現自定義水印相機知識點1、自定義相機+預覽相機2、截屏拍照加水印3、關於不使用intent來傳輸圖片 俗話說,有圖有
微信6.0主界面:(1)整體采用垂直的LinearLayout線性布局(2)最上面是ActionBar,搜索框SearchView,Overflow(含有4個單選菜單項)
0x01.簡介AsyncTask is designed to be a helper class around Thread and Handler and does