A first hand look at building an Android application

 

http://www.youtube.com/watch?v=I6ObTqIiYfE

視頻中使用的SDK是比較早的版本,有些API已經改了。

 

  1.     public void onCreate(Bundle savedInstanceState) {
  2.         super.onCreate(savedInstanceState);
  3.         // setContentView(R.layout.main);
  4.         Cursor c = this.getContentResolver().query(People.CONTENT_URI, nullnullnullnull);
  5.         this.startManagingCursor(c);
  6.         String[] columns = new String[] { People.NAME };
  7.         int[] names = new int[] { R.id.row_entry };
  8.         mAdapter = new SimpleCursorAdapter(this, R.layout.main, c, columns, names);
  9.         this.setListAdapter(mAdapter);
  10.     }
  11.     @Override
  12.     protected void onListItemClick(ListView l, View v, int position, long id) {
  13.         super.onListItemClick(l, v, position, id);
  14.         
  15.         Intent intentCall = new Intent(Intent.ACTION_CALL);
  16.         Cursor c = (Cursor) mAdapter.getItem(position);
  17.         String phoneId = c.getString(c.getColumnIndex(People.PRIMARY_PHONE_ID));
  18.         intentCall.setData(Uri.withAppendedPath(Phones.CONTENT_URI, phoneId));
  19.         startActivity(intentCall);
  20.     }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章