一些经验(一)

通过电脑安装apk到手机方法

 

1.Apk可由网上下载或通过Eclipse工程自动生成,会生成在工程bin下

2.一种方法是先U盘模式拷到SD卡上,再有手机上打开安装;

3.另一种是安装91手机助手等助手软件,打开手机上USB调试选项,用助手软件操作安装

4.连接eclipse,手机连接DDMS,由DDMS 安装

5.通过adb命令安装, 命令为adb install ***.apk

 

Get code

•To clone one of these trees, install git, and run:
•git clone git://android.git.kernel.org/ + project path.
•like: git clone git://android.git.kernel.org/platform/packages/apps/Mms.git
•To clone the entire platform, install repo, and run:
•mkdir mydroid
• cd mydroid
• repo init -u git://android.git.kernel.org/platform/manifest.git

 repo sync

Android layout

Android系统为我们提供了多种模板进行选择(android.R.layout),如
•Ø Simple_list_item_1 每项有一个TextView
•Ø Simple_list_item_2 每项有两个TextView
•Ø Simple_list_item_checked 带CheckView的项
•Ø Simple_list_item_multiple_choise 每项有一个TextView并可以多选
•Ø Simple_list_item_single_choice 每项有一个TextView,但只能进行单选。
ArrayAdapter
public class ipList extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.iplist); String[] data = { "Item1", "Item2", "Item3", "Item4", "Item5" }; ListView listView = (ListView) getListView(); listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data)); } }
SimpleCursorAdapter
 //从数据库中查询Cursor    cursor = adapter.getAllNotes();    startManagingCursor(cursor);       //设置要显示的数据源中的列名(需要包含在cursor中)    String[] from = new String[] { DiaryDbAdapter.KEY_COLUMN_TITLE,                 DiaryDbAdapter.KEY_COLUMN_CREATEED };       //显示的View(自定义模板中的View)    int[] to = new int[] { R.id.txtRowTitle, R.id.txtRowCreateed };    //绑定    SimpleCursorAdapter notes = new SimpleCursorAdapter(this,                 R.layout.diaryrow, cursor, from, to);    setListAdapter(notes);
SimpleAdapter
   SimpleAdapter将一个List做为数据源,可以让ListView进行更加个性化的显示。而List中的第一项是个Map<String,?>(用到泛型),其中Map中的每项将与ListView中的每项进行一一对应绑定。Ok,看一下构造:    SimpleAdapter(Context context,List<? Extends Map<String,?>> data,int resource,String [] form, int [] to);   ² Context:当前上下文,一般把Activity.this传递进行。 ² Data: 数据源。 ² Resource: 自定义的layout模板资源,可以用 R.layout.xxx获取引用。 ² Form: 定义ListView中的每一项数据索引,索引来自于Map<String,?>,即指定要显示的内容。 ² To:View数组,在ListView模板中的定义View,与Form中需要一一对应。 事例代码:       List<Hashtable<String, Object>> listContent = new ArrayList<Hashtable<String, Object>>();         for (int i = 0; i < deviceList.size(); i++) {          Hashtable<String, Object> table = new Hashtable<String, Object>();          table.put("name", deviceList.get(i).Name);          table.put("address", deviceList.get(i).Address);          table.put("type", deviceList.get(i).Type + "");              listContent.add(table);       }         adapter = new SimpleAdapter(HeartActivity.this, listContent, R.layout.child, //自定义的layout  new String[] { "name", "address" },  new int[] {R.id.txtDeviceName, R.id.txtDeviceAddress });         setListAdapter(adapter); 以上代码使用了Hashtable做为一个Map,并添加到一个List<Hashtable<String, Object>>当中。 之后new一个SimpleAdapter,注意SimpleAdapter是如何生成的。

你可能感兴趣的:(一些经验(一))