写代码的人

Archive for the ‘android学习笔记’ Category

按钮事件,模式窗体

layout: <Button android:id=”@+id/firstButton” android:layout_width=”fill_parent” android:layout_height=”wrap_content” /> activity: public class FirstActivity extends Activity { private Button firstButton; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); firstButton = (Button)findViewById(R.id.firstButton); firstButton.setText(R.string.firstButton); firstButton.setOnClickListener(new FirstButtonListener()); } class FirstButtonListener implements OnClickListener{ @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(FirstActivity.this, SecondActivity.class); startActivity(intent); } } } AndroidManifest.xml文件: <application android:icon=”@drawable/icon” [...]

android第三节–relative布局

代码: <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:padding=”10px”> <TextView android:id=”@+id/label” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”Type Here:” /> <EditText android:id=”@+id/entry” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:background=”@android:drawable/editbox_background” android:layout_below=”@+id/label”/> <Button android:id=”@+id/ok” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_below=”@id/entry” android:layout_alignParentRight=”true” android:layout_marginLeft=”10px” android:text=”ok”/> <Button android:id=”@+id/cancel” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_toLeftOf=”@id/ok” android:layout_alignTop=”@id/ok” android:text=”cancel”/> </RelativeLayout> 效果: 界面使用xml跟silverlight很像

android第二节–linear布局

代码: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <LinearLayout android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:orientation=”horizontal” android:layout_weight=”1″ > <TextView android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:text=”red” android:background=”#FA0012″ android:layout_weight=”1″ /> <TextView android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:text=”gray” android:background=”#FCC603″ android:layout_weight=”1″ /> <TextView android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:text=”black” android:background=”#6AB32E” android:layout_weight=”1″ /> <TextView android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:text=”blue” android:background=”#030FE3″ android:layout_weight=”1″ /> </LinearLayout> <LinearLayout android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:orientation=”vertical” android:layout_weight=”1″ > <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”black” [...]

android第一节–table布局

<?xml version=”1.0″ encoding=”utf-8″?> <TableLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:stretchColumns=”0″ > <TableRow> <TextView android:text=”@string/row1_column1″ android:padding=”8dip” android:background=”#ccc” /> <TextView android:text=”@string/row1_column2″ android:gravity=”center_vertical” android:padding=”8dip” android:background=”#000ccc” /> <TextView android:text=”@string/row1_column3″ android:gravity=”right” android:padding=”8dip” android:background=”#c00000″ /> </TableRow> <TableRow> <TextView android:text=”@string/row2_column1″ android:padding=”5dip” /> <TextView android:text=”@string/row2_column2″ android:gravity=”right” android:padding=”5dip” /> <TextView android:text=”@string/row2_column3″ android:padding=”5dip” /> </TableRow> </TableLayout> 效果:

android第一篇

1, 喜欢这个小机器人 2,可以使用java语言开发 3,开发工具使用熟悉的eclipse 4,自己一直想在移动的领域里做点东西 5,此系统是google公司拥有的 6,在美国的市场android智能手机的销量超过iPhone 7,我所知道的首个开源的移动系统

加关注

Get every new post delivered to your Inbox.