当前位置:首页 > 芯闻号 > 充电吧
[导读]1、引用string.xml中的字符串1) 代码中 R.string.hello_world2) XML中@string/hello_world2、AndroidManifestandroid:lab

1、引用string.xml中的字符串

1) 代码中 R.string.hello_world

2) XML中@string/hello_world

2、AndroidManifest

android:label指定Activity中标题栏的内容、也是应用程序的名称。

intent-filter中的

标识MainActivity是应用的主程序。

3、Toast duration

Toast.LENGTH_SHORT//2S
Toast.LENGTH_LONG//3.5s

4、在Activity中使用Menu
重写onCreateOptionsMenu()

@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;//表示允许将菜单显示出来
	}

重写 onOptionsItemSelected()

@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		switch(id){
		case R.id.add_item:
			Toast.makeText(this, "add", Toast.LENGTH_SHORT).show();
			break;
		case R.id.remove_item:
			Toast.makeText(this, "remove", Toast.LENGTH_SHORT).show();
			break;
			default:
		}






本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭