2011年2月21日
摘要: Activity间的简单数据传递 Bundle 记录如下:1.建2个Activity 跳转2: 第一个文件   Intent intent = new Intent(); intent.setClass(Activity1.this,Activity2.class); //new一个Bundle对象,并将要传递的数据传入 Bundle bundle = new Bundle(); bundle.putDouble("height",height); bundle.putString("sex",sex); //将Bundle对象assign给Intent intent.putExtras( 阅读全文
posted @ 2011-02-21 15:26 sunwei_07 阅读(502) 评论(2) 推荐(0) 编辑
  2011年2月17日
摘要: LinearLayoutm_LinearLayout;ListViewm_ListView;/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);/* 创建LinearLayout布局对象 */m_LinearLayout = new LinearLayout(this);/* 设置布局LinearLayout的属性 */m_LinearLayout.setOrient 阅读全文
posted @ 2011-02-17 19:27 sunwei_07 阅读(695) 评论(1) 推荐(0) 编辑
  2011年2月16日
摘要: 1.在raw目录放一个mp3文件:test.mp3;2.建一个MediaPlay的Service文件MusicService.javapublic class MusicService extends Service{//MediaPlayer对象private MediaPlayerplayer;public IBinder onBind(Intent arg0){return null;}public void onStart(Intent intent, int startId){super.onStart(intent, startId);//这里可以理解为装载音乐文件player = 阅读全文
posted @ 2011-02-16 13:56 sunwei_07 阅读(679) 评论(0) 推荐(0) 编辑
摘要: public void onCreate(Bundle savedInstanceState){TextView tv = new TextView(this);String string = "";super.onCreate(savedInstanceState);//得到ContentResolver对象 ContentResolver cr = getContentResolver(); //取得电话本中开始一项的光标 Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, n 阅读全文
posted @ 2011-02-16 13:23 sunwei_07 阅读(677) 评论(4) 推荐(0) 编辑
摘要: 首先在layout里建2个xml文件分别有按钮1和按钮2JAVA代码:1.public class Activity01 extends Activity{public void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);/* 设置显示main.xml布局 */setContentView(R.layout.main);/* findViewById(R.id.button1)取得布局main.xml中的button1 */Button button = (Button) findViewByI 阅读全文
posted @ 2011-02-16 09:25 sunwei_07 阅读(768) 评论(0) 推荐(0) 编辑
  2011年2月15日
摘要: 1.string.xml<?xml version="1.0" encoding="utf-8"?><resources><string name="hello">Hello World, ActivityMain!</string><string name="app_name">ActivityMain</string><string name="name">账号:</string><string name="pass">密码:</string></resource 阅读全文
posted @ 2011-02-15 16:12 sunwei_07 阅读(766) 评论(0) 推荐(0) 编辑
摘要: 首先我们是在res->values->string.xml里面加了如下一句(黑体):<?xmlversion="1.0"encoding="utf-8"?><resources><stringname="hello">HelloWorld,HelloAndroid</string><stringname="app_name">HelloAndroid</string><stringname="textView_text">欢迎来到博客</string></resources> 阅读全文
posted @ 2011-02-15 16:09 sunwei_07 阅读(760) 评论(0) 推荐(1) 编辑