当前位置: 网学 > 编程文档 > Android > 正文

新版Android开发教程9

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: myeducs.cn 发布时间: 13/03/17

【网学网提醒】:网学会员为您提供新版Android开发教程9参考,解决您在新版Android开发教程9学习中工作中的难题,参考学习


    stephenson37(网学)贡献
    
    Android编程基础
    封面
    1
    Android编程基础
    AndroidUI编程基础3
    EditText与TextView共舞
    setOnKeyListener事件
    ①新建工程
    ②在main.xml布局中添加UI元素:一个EditText和一个TextView
    ③在mainActivity.java主Activity中修改代码packagezyf.EX_Ctrl_1;importimportimportimportimportimportandroid.app.Activity;android.os.Bundle;android.view.KeyEvent;android.view.View;android.widget.EditText;android.widget.TextView;
    publicclassEX_Ctrl_1extendsActivity{privateTextViewmTextView01;
    2
    Android编程基础
    privateEditTextmEditText01;/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);setContentView(R.layout.main);/*取得TextView,EditText*/mTextView01=(TextView)findViewById(R.id.myTextView);mEditText01=(EditText)findViewById(R.id.myEditText);处理EditText键入事件/*设置EditText用OnKeyListener事件来启动*/newmEditText01.setOnKeyListener(newEditText.OnKeyListener(){@OverridepublicbooleanonKey(Viewv,intkeyCode,KeyEventevent){//TODOAuto-generatedmethodstubmTextView01.setText(mEditText01.getText().toString());returnfalsefalse;}});}}④结果
    3
    Android编程基础设计具有背景图的按钮
    ImageButton的焦点及事件处理
    ①②新建工程准备png图片资源clickimage.png,lostfocusimage.png,onfocusimage.png
    ③在string.xml中添加字符串EX_Ctrl_2图片按钮状态:未知图片按钮状态:GotFocus图片按钮状态:LostFocus图片按钮状态:GotClick一般按钮④修改main.xml布局,添加布局元素
    ⑤修改mainActivity.javapackagezyf.EX_Ctrl_2;importandroid.app.Activity;importandroid.os.Bundle;importandroid.view.View;importandroid.view.View.OnClickListener;importandroid.view.View.OnFocusChangeListener;importandroid.widget.Button;importandroid.widget.ImageButton;importandroid.widget.TextView;publicclassEX_Ctrl_2extendsActivity{/**Calledwhentheactivityisfirstcreated.*//*声明三个
    对象变量(图片按钮,按钮,与TextView)*/privateImageButtonmImageButton1;privateButtonmButton1;privateTextViewmTextView1;@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);setContentView(R.layout.main);/*通过findViewById构造三个对象*/mImageButton1=(ImageButton)findViewById(R.id.image_Button);mButton1=(Button)findViewById(R.id.normal_Button);mTextView1=(TextView)findViewById(R.id.show_TextView);/*通过OnFocusChangeListener来响应ImageButton的onFous事件*/newmImageButton1.setOnFocusChangeListener(newOnFocusChangeListener(){publicvoidonFocusChange(Viewarg0,booleanisFocused){//TODOAuto-generatedmethodstub/*若ImageButton状态为onFocus改变ImageButton的图片并改变textView的文字*/if(isFocused==true{true)mTextView1.setText(R.string.onfocus);mImageButton1.setImageResource(R.drawable.onfocusimage);
    5
    Android编程基础
    }/*若ImageButton状态为offFocus改变ImageButton的图片并改变textView的文字*/else{mTextView1.setText(R.string.lostfocus);mImageButton1.setImageResource(R.drawable.lostfocusimage);}}});/*通过onClickListener来响应ImageButton的onClick事件*/newmImageButton1.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewv){//TODOAuto-generatedmethodstub/*若ImageButton状态为onClick改变ImageButton的图片并改变textView的文字*/mTextView1.setText(R.string.onclick);mImageButton1.setImageResource(R.drawable.clickimage);}});/*通过onClickListener来响应Button的onClick事件*/newmButton1.setOnClickListener(newOnClickListener(){@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstub/*若Button状态为onClick改变ImageButton的图片*并改变textView的文字*/mTextView1.setText(R.string.lostfocus);mImageButton1.setImageResource(R.drawable.lostfocusimage);}});}}⑥结果
    6
    Android编程基础使用XML实现按钮改变焦点设置背景图
    Button的android:background属性
    设置按钮背景图片:onFocus()与onClick()事件处理Item的android:state_focused和android:state_pressed属性实现①新建工程②准备png背景图片defaultimage.png,onfocusimage.png,clickimage.png
    clickimage
    defaultimage.png
    onfocusimage.png
    ③在main.xml布局中添加一个ImageButton和一个Button(作对比)
    7
    Android编程基础
    ④在drawable文件夹中添加一个advancedbutton.xml设置和标签失去焦点时⑤设置ImageButton的android:background属性值⑥结果
    默认时
    利用XML来改变按钮背景图片
    8
    Android编程基础给圣诞老人的信息
    Toast--Android专属浮动小提示
    ①新建工程
    ②在string.xml中添加
    字符串EX_Ctrl_3亲爱的圣诞老人:送出愿望你的愿望:已送达圣诞老人信箱!③在main.xml布局中添加UI元素:一个TextView,一个EditView和一个Button
    
    9
    Android编程基础
    ④修改mainActivity.java文件packagezyf.EX_Ctrl_3;importimportimportimportimportimportimportandroid.app.Activity;android.os.Bundle;android.text.Editable;android.view.View;android.widget.Button;android.widget.EditText;android.widget.Toast;
    publicclassEX_Ctrl_3extendsActivity{/**Calledwhentheactivityisfirstcreated.*//*声明两个对象变量(按钮与编辑文字)*/privateButtonmButton;privateEditTextmEditText;@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);setContentView(R.layout.main);/*通过findViewById()取得对象*/mButton=(Button)findViewById(R.id.Button_Send);mEditText=(EditText)findViewById(R.id.EditText_Wish);/*设置onClickListener给Button对象聆听onClick事件*/newmButton.setOnClickListener(newButton.OnClickListener(){@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstub/*声明字符串变量并取得用户输入的EditText字符串*/EditableStr;Str=mEditText.getText();/*使用CharSequence类getString()方法从XML中获取String*/CharSequencestring2=getString(R.string.yourWish);CharSequencestring3=getString(R.string.hasSend);/*使用系统标准的makeText()方式来产生Toast信息*/thisToast.makeText(EX_Ctrl_3.thisthis,string2+Str.toString()+string3,Toast.LENGTH_LONG).show();/*清空EditText*/mEditText.setText("");}});}}
    10
    Android编程基础
    ⑤结果
    11
    Android编程基础Toast-Toast--显示View的提示
    Toast显示一个ImageView
    ①②新建工程在drawable文件夹中添加一副png图片:argon.png
    ③修改mainActivity.java文件packagezyf.EX_Ctrl_3_B;importimportimportimportandroid.app.Activity;android.os.Bundle;android.widget.ImageView;android.widget.Toast;
    publicclassEX_Ctrl_3_BextendsActivity{/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);/*设置主屏布局*/setContentView(R.layout.main);/*创建新Toast对象*/newthisToastshowImageToast=newToast(thisthis);/*创建新ImageView对象*/newthisImageViewimageView=newImageView(thisthis);/*从资源中获取图片*/imageView.setImageResource(R.drawable.argon);/*设置Toast上的View--(ImageVie
    w)*/showImageToast.setView(imageView);/*设置Toast显示时间*/showImageToast.setDuration(Toast.LENGTH_LONG);/*显示Toast*/showImageToast.show();}}
    12
    Android编程基础
    ④结果
    13
    Android编程基础
    Toast显示一个Button
    ①新建工程②修改mainActivity.java文件packagezyf.EX_Ctrl_3_B;importandroid.app.Activity;importandroid.os.Bundle;importandroid.view.View;importandroid.widget.Button;importandroid.widget.Toast;publicclassEX_Ctrl_3_BextendsActivity{/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);/*设置主屏布局*/setContentView(R.layout.main);/*创建新Toast对象*/thisToastshowImageToast=newToast(thisthis);///*新建Button对象*/thisButtonbutton=newButton(thisthis);button.setText("OK");/*设置Toast上的View--(Button)*/showImageToast.setView(button);/*设置Toast显示时间*/showImageToast.setDuration(Toast.LENGTH_LONG);/*显示Toast*/showImageToast.show();}}③结果
    14
    Android编程基础
    Toast显示一个TextView
    ①新建工程
    ②修改mainActivity.java文件packagezyf.EX_Ctrl_3_B;importandroid.app.Activity;importandroid.os.Bundle;importandroid.widget.TextView;importandroid.widget.Toast;publicclassEX_Ctrl_3_BextendsActivity{/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);/*设置主屏布局*/setContentView(R.layout.main);/*创建新Toast对象*/thisToastshowImageToast=newToast(thisthis);/*新建TextView对象*/newthisTextViewtext=newTextView(thisthis);/*设置TextView内容*/text.setText("显示在Toast中的TextView");/*设置Toast上的View--(TextView)*/showImageToast.setView(text);/*设置Toast显示时间*/showImageToast.setDuration(Toast.LENGTH_LONG);/*显示Toast*/showImageToast.show();}}③结果
    15
    Android编程基础AlertDialog.Builder提示对话框
    ①新建工程
    ②修改mainActivity.java文件packagezyf.EX_Ctrl_3_B;importandroid.app.Activity;importandroid.app.AlertDialog;importandroid.os.Bundle;publicclassEX_Ctrl_3_BextendsActivity{/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);/*设置主屏布局*/setContentView(R.layout.main);/*新建一个AlertDialog.Builder对象*/newthisAlertDialog.Buildermy_ADialog=newAlertDialog.Builder(thisthis);/*设置标题*/my_ADialog.setTitle("Android提示");/*设置显示消息*/my_ADialog.setMessage("AlertDialog.Builder提示对话框消息!!");/*显示*/my_ADialog.show();}}③结果
    16
    Android编程基础同意条款
    CheckBox的isChecked属性
    ①创建新工程
    ②
    在string.xml中添加字符串Ex_Ctrl_4请勾选我同意您已接受同意!!您未同意!!全部许可③修改main.xml布局,添加UI元素
    
    17
    Android编程基础
    ④修改mainActivity.java文件packagezyf.Ex_Ctrl_4;importimportimportimportimportimportimportandroid.app.Activity;android.graphics.Color;android.os.Bundle;android.view.View;android.widget.Button;android.widget.CheckBox;android.widget.TextView;
    publicclassEx_Ctrl_4extendsActivity{/**Calledwhentheactivityisfirstcreated.*/privateTextViewshowAdvice,yourChoiceshow;privateCheckBoxiAccept;privateButtonok;@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);setContentView(R.layout.main);/*findViewById()从资源ID获取资源对象*/showAdvice=(TextView)findViewById(R.id.TextView_Guide);yourChoiceshow=(TextView)findViewById(R.id.TextView_youChoiceShow);iAccept=(CheckBox)findViewById(R.id.CheckBox_Accept);ok=(Button)findViewById(R.id.Button_OK);/*获取XML中字符串*/CharSequencetitleString=getString(R.string.allOK);/*设置复选框标题*/iAccept.setHint(titleString);/*设置复选框标题字体颜色*/iAccept.setHintTextColor(Color.RED);/*将CheckBox设置成未选中*/falseiAccept.setChecked(falsefalse);/*将Button设置成不可选*/falseok.setEnabled(falsefalse);newiAccept.setOnClickListener(newCheckBox.OnClickListener(){@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstubifif(iAccept.isChecked()){
    18
    Android编程基础
    trueok.setEnabled(truetrue);yourChoiceshow.setText(R.string.accept);else}elseelse{falseok.setEnabled(falsefalse);yourChoiceshow.setText(R.string.Notaccept);}}});newok.setOnClickListener(newButton.OnClickListener(){@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstubifif(iAccept.isChecked()){showAdvice.setText(R.string.accept);}}});}}⑤结果
    19
    Android编程基础购物列表
    多选项CheckBox的应用
    ①新建工程
    ②在string.xml中添加字符串Ex_Ctrl_5网上购物商品清单您选择购买的商品:纽曼MP4Beyond乐队CDAndroid程序员指南③修改main.xml布局,
    添加UI元素
        20
    Android编程基础
    android:id="@+id/CheckBox_book"android:layout_width="180px">④修改mainActivity.java,添加逻辑判断packagezyf.Ex_Ctrl_5;importimportimportimportimportimportandroid.app.Activity;android.os.Bundle;android.widget.CheckBox;android.widget.CompoundButton;android.widget.TextView;android.widget.CompoundButton.OnCheckedChangeListener;
    publicclassEx_Ctrl_5extendsActivity{/**Calledwhentheactivityisfirstcreated.*/privateTextViewshowyourChoice_TextView;privateCheckBoxmp4_CheckBox,musicCD_CheckBox,book_CheckBox;privateStringshowinfo;@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);setContentView(R.layout.main);/*findViewById()从XML中获取资源对象*/showyourChoice_TextView=(TextView)findViewById(R.id.TextView_yourWoodsList);mp4_CheckBox=(CheckBox)findViewById(R.id.CheckBox_MP4);musicCD_CheckBox=(CheckBox)findViewById(R.id.CheckBox_musicCD);book_CheckBox=(CheckBox)findViewById(R.id.CheckBox_book);/*为三个CheckBox设置选择状态改变事件监听器*/
    21
    Android编程基础
    mp4_CheckBox.setOnCheckedChangeListener(CheckedChangeListener);musicCD_CheckBox.setOnCheckedChangeListener(CheckedChangeListener);book_CheckBox.setOnCheckedChangeListener(CheckedChangeListener);/*从XML中获取显示信息String*/showinfo=getString(R.string.yourChocieWoods_text);}/*内部接口实现*/privateOnCheckedChangeListenerOnCheckedChangeListener(){
    CheckedChangeListener
    =
    new
    @OverridepublicvoidonCheckedChanged(CompoundButtonbuttonView,booleanisChecked){//TODOAuto-generatedmethodstub/*处理选中状态改变事件,动态显示选择结果*/if(mp4_CheckBox.isChecked()){showinfo=getString(R.string.woods_Text_MP4)+"\n";showString();}elseif(musicCD_CheckBox.isChecked()){showinfo=getString
    (R.string.woods_Text_musicCD)+"\n";showString();}elseif(book_CheckBox.isChecked()){showinfo=getString(R.string.woods_Text_book)+"\n";showString();}if(mp4_CheckBox.isChecked()&;&;musicCD_CheckBox.isChecked()){showinfo=getString(R.string.woods_Text_MP4)+"\n"+getString(R.string.woods_Text_musicCD)+"\n";showString();}elseif(mp4_CheckBox.isChecked()&;&;book_CheckBox.isChecked()){showinfo=getString(R.string.woods_Text_MP4)+"\n"+getString(R.string.woods_Text_book)+"\n";showString();}elseif(musicCD_CheckBox.isChecked()&;&;book_CheckBox.isChecked()){showinfo=getString(R.string.woods_Text_musicCD)+"\n"+getString(R.string.woods_Text_book)+"\n";showString();}if(mp4_CheckBox.isChecked()&;&;musicCD_CheckBox.isChecked()&;&;book_CheckBox.isChecked()){showinfo=getString(R.string.woods_Text_MP4)+"\n"
    22
    Android编程基础
    +getString(R.string.woods_Text_musicCD)+"\n"+getString(R.string.woods_Text_book)+"\n";showString();}if(mp4_CheckBox.isChecked()==false&;&;musicCD_CheckBox.isChecked()==false&;&;book_CheckBox.isChecked()==false{false)showyourChoice_TextView.setText("");}}publicvoidshowString(){showyourChoice_TextView.setText(showinfo);}};}⑤结果
    23
    Android编程基础RadioButton单选
    RadioGroup组与onCheckedChanged事件
    ①新建工程
    ②string.xml中添加字符串Ex_Ctrl_6帅哥美女请问你是??③修改mian.xml布局,添加UI元素
    
    24
    Android编程基础
    ④修改mainActivity.java文件packagezyf.Ex_Ctrl_6;importimportimportimportimportandroid.app.Activity;android.os.Bundle;android.widget.RadioButton;android.widget.RadioGroup;android.widget.TextView;
    publicclassEx_Ctrl_6extendsActivity{/**Calledwhentheactivityisfirstcreated.*/privateTextViewanswer_TextView;privateRadioButtonboy_RadioButton,girl_RadioButton;privateRadioGroupradioGroup;@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);setContentView(R.layout.main);/*findViewById()从XML中获取资源对象*/answer_TextView=(TextView)findViewById(R.id.TextView_Ask_And_Show);
    radioGroup=(RadioGroup)findViewById(R.id.RadioGroup);boy_RadioButton=(RadioButton)findViewById(R.id.RadioButton_Boy);girl_RadioButton=(RadioButton)findViewById(R.id.RadioButton_Gril);/*给单RadioGroup添加状态改变监听器*/newradioGroup.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener(){@OverridepublicvoidonCheckedChanged(RadioGroupgroup,intcheckedId){//TODOAuto-generatedmethodstubifif(boy_RadioButton.isChecked()){answer_TextView.setText(R.string.iam_Boy);else}elseelse{answer_TextView.setText(R.string.iamGirl);}}});}}
    25
    Android编程基础
    ⑤结果
    26
    Android编程基础RadioButton猜猜看
    猜猜我是??
    ①新建项目
    ②准备三张png图片ic_menu_close_clear_cancel.png
    right.png
    wrong.png
    ③在string.xml中添加要使用的字符串Ex_Ctrl_6帅哥name="iamGirl">美女name="ask">猜猜我是??name="answer_Q">回答name="clean">清空name="showAnswerTitle_YES">恭喜!name="showAnswerTitle_NO">很遗憾!name="about_dialog_ok">OK
    您答对了!!哈哈,错误!正确答案是:
④在main.xml中添加UI元素
    
    27
    Android编程基础
    
    ⑤修改mainActivity.java文件packagezyf.Ex_Ctrl_6;importimportimportimportimportjava.util.Random;android.app.Activity;android.app.AlertDialog;android.os.Bundle;android.view.Menu;
    28
    Android编程基础
    importimportimportimportimportimportimportandroid.view.MenuItem;android.view.View;android.widget.Button;android.widget.RadioButton;android.widget.RadioGroup;android.widget.TextView;android.widget.Toast;
    publicclassEx_Ctrl_6extendsActivityimplementsButton.OnClickListener{/**Calledwhentheactivityisfirstcreated.*/privateTextViewanswer_TextView;privateRadioButtonboy_RadioButton,girl_RadioButton;privateRadioGroupradioGroup;privateButtonanswer_Button,clean_Button;privateString[]boy_girl;privateAlertDialog.BuildershowRightorNot;privateMenuItemexit;@OverridepublicvoidonCreate(BundlesavedInstanceState){supersuper.onCreate(savedInstanceState);setContentView(R.layout.main);/*结果显示对话框*/thisshowRightorNot
    =newAlertDialog.Builder(thisthis);/*findViewById()从XML中获取资源对象*/answer_TextView=(TextView)findViewById(R.id.TextView_Ask_And_Show);radioGroup=(RadioGroup)findViewById(R.id.RadioGroup);boy_RadioButton=(RadioButton)findViewById(R.id.RadioButton_Boy);girl_RadioButton=(RadioButton)findViewById(R.id.RadioButton_Gril);answer_Button=(Button)findViewById(R.id.answer_The_Q_button);clean_Button=(Button)findViewById(R.id.clean_The_Q_button);/*答案数组*/boy_girl=newString[]{"Boy","Girl","Boy","Girl","Boy","Girl","Boy","Girl","Boy"};/*按钮设置成不可选*/falseanswer_Button.setEnabled(falsefalse);falseclean_Button.setEnabled(falsefalse);
    29
    Android编程基础
    /*给单RadioGroup添加状态改变监听器*/newradioGroup.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener(){@OverrideintpublicvoidonCheckedChanged(RadioGroupgroup,intcheckedId){//TODOAuto-generatedmethodstub/*判断显示*/if(boy_RadioButton.isChecked()){answer_TextView.setText(R.string.iam_Boy);}else{answer_TextView.setText(R.string.iamGirl);}}});newboy_RadioButton.setOnClickListener(newRadioGroup.OnClickListener(){@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstub/*按钮设置成可选*/trueanswer_Button.setEnabled(truetrue);trueclean_Button.setEnabled(truetrue);}});newgirl_RadioButton.setOnClickListener(newRadioGroup.OnClickListener(){@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstub/*按钮设置成可选*/trueanswer_Button.setEnabled(truetrue);trueclean_Button.setEnabled(truetrue);}});/*设置按钮事件监听器*/thisanswer_Button.setOnClickListener(thisthis);thisclean_Button.setOnClickListener(thisthis);}
    30
    Android编程基础
    @OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstubif(v.getId()==R.id.answer_The_Q_button){if(boy_RadioButton.isChecked()){checkTheAnswer("Boy");elseif(girl_RadioButton.isChecked()){}checkTheAnswer("Girl");}}if(v.getId()==R.id.clean_The_Q_button){/*按钮设置成未选取*/falseboy_RadioButton.setChecked(falsefalse);falsegirl_RadioButton.setChecked(falsefalse);/*按钮设置成不可选*/falseanswer_Button.setEnabled(falsefalse);falseclean_Button.setEnabled(falsefalse);answer_TextView.setText(R.string.ask);}}privatevoidcheckTheAnswer(Stringcheckstring){//TODOAuto-generatedmethodstub/*检测提示*/thisToast.makeText(this"检测答案…………",Toast.LENGTH_SHORT).show();this,/*获取随机数*/Randomrandom=newRandom();intindex=random.nextInt(9);if(boy_girl[index].equals(checkstring)){/*回答正确,设置提示对话框,显示结果*/showRightorNot.setIcon(R.drawable.right);showRightorNot.setTitle(R.string.showAnswerTitle_YES);showRightorNot.setPositiveButton(R.string.about_dialog_ok,nullnull);
    showRightorNot.setMessage(R.string.right).show();thisToast.makeText(thisthis,getString(R.string.answerIS)+boy_girl[index],Toast.LENGTH_LONG).show();}else{/*回答错误,设置提示对话框,显示结果*/showRightorNot.setIcon(R.drawable.wrong);showRightorNot.setTitle(R.string.showAnswerTitle_NO);showRightorNot.setPositiveButton(R.string.about_dialog_ok,nullnull);
    31
    Android编程基础
    showRightorNot.setMessage(R.string.wrong).show();thisToast.makeText(thisthis,getString(R.string.answerIS)+boy_girl[index],Toast.LENGTH_LONG).show();}}@OverridepublicbooleanonCreateOptionsMenu(Menumenu){//TODOAuto-generatedmethodstub/*添加退出菜单*/exit=menu.add("Exit");/*设置退出菜单图片*/exit.setIcon(R.drawable.ic_menu_close_clear_cancel);returnsupersuper.onCreateOptionsMenu(menu);}@OverridepublicbooleanonOptionsItemSelected(MenuItemitem){//TODOAuto-generatedmethodstub/*结束Activity*/finish();returnsupersuper.onOptionsItemSelected(item);}}⑥结果
    32
    Android编程基础
    封面
    33
    1
    
  • 上一篇资讯: 时尚作文 集合
  • 下一篇资讯: 新版Android开发教程5
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号