1 给文本框设置内容
TextView txtResult = (TextView) findViewById(R.id.txtResult);
txtResult.setText(“我是徐海涛”);
2 查找View
findViewById(R.id.setting).setVisibility(View.GONE);
3 意图
若果意图过滤器中没有定义data,只定义action和category,那么Intent中的动作action和范畴category只要出现在意图过滤器intent-filter中,即可激活Activity,intent是过滤器的子集)
如果一个Activity的意图过滤器中定义了data(scheme/host/path/mimeType),那么意图中必须完全按照过滤器的data要求出示,否则无法激活Activity
接收端取出数据
Intent intent=this.getIntent();
bunde = intent.getExtras();
String sex = bundle.getString(“sex”);
Double height = bundle.getDouble(“height”);
Bundle2.this.setResult(RESULT_OK,intent);
Bundle2.this.finish();
4 线性布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18dp"
android:padding="8dp"
android:id="@+id/txtResult" />
<View
android:layout_width="match_parent"
android:background="#999"
android:layout_height="25dp" />
<ScrollView
android:layout_width="match_parent"
android:layout_above="@+id/btn"
android:layout_weight="1"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="12dp"
android:id="@+id/txtLog" />
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setting"
android:id="@+id/setting"
android:onClick="onClick"
android:layout_alignParentBottom="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/start"
android:id="@+id/btn"
android:onClick="onClick"
android:layout_alignParentBottom="true" />
</LinearLayout>
线性布局案例二
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="slot name"
android:id="@+id/textView2" android:layout_gravity="center_horizontal"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="words"
android:id="@+id/textView" android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="status"
android:id="@+id/textView3" android:layout_gravity="center_horizontal"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="submit"
android:id="@+id/button"/>
</LinearLayout>
FR:海涛高软(QQ群:386476712)