码迷,mamicode.com
首页 > 移动开发 > 详细

Android第二天

时间:2017-01-16 22:26:57      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:for   stop   布局文件   str   instance   led   onrestart   使用   long   

1.从看得见的活动入手

protected void onCreate(Bundle savedInstanceState) {    
    super.onCreate(savedInstanceState);        //调用了父类的onCreate()方法。
setContentView(R.layout.aty_timeline);       //设置布局文件。

}

隐藏标题栏:requestWindowFeature(Window.FEATURE_NO_TITLE),放在setContentView(R.layout.aty_timeline)的前面。
2.布局文件
技术分享

 3.Toast的使用

Toast.makeText(FirstActivity.this,R.string.abc,Toast.LENGTH_LONG).show();

4.销毁活动,一句话。
finish();
5.Intent的用法。
显示+隐式
显示:
Intent i = new Intent(AtyLogin.this,AtyTimeline.class);
i.putExtra(Config.KEY_TOKEN,token);
startActivity(i);

获取Intent传的值:
Intent data = getIntent();
msg = data.getStringExtra(Config.KEY_MSG);

隐式:配置文件中添加category,自己查书了解。
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.baidu.com"));
startActivity(intent);
6.传递与返回数据:
传送:
Intent intent = new Intent(AtyLogin.this,AtyTimeline.class);
startActivityForResult(intent,1);
接收:
Intent intent = new Intent();
intent.putExtra("data_return","Hello!");
setResult(RESULT_OK,intent);
此方法非常重要,专门用于向上一个活动传递数据,setResult有两个参数,第一个是返回处理结果,RESULT_OK或者RESULT_CANCELED。第二个参数是把带有数据的intent传递回去。
7.活动的生命周期:(一定弄明白,记在心里!)
onCreate
onStart
onResume
onPause
onStop
onDestroy
onRestart
技术分享

 



 8.进度条
final ProgressDialog pd = ProgressDialog.show(AtyMessage.this,getResources().getString(R.string.connecting),getResources().getString(R.string.connecting_to_server));
pd.dismiss();
 


 
 

Android第二天

标签:for   stop   布局文件   str   instance   led   onrestart   使用   long   

原文地址:http://www.cnblogs.com/pangshuangle/p/6291067.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!