TextView 碎片代码
xml文件代码(自动产生的代码)
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
xml文件代码(自行添加)
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A new Activity has been started."
/>
自己建立一个新的类,初始代码如下,再增加相应的xml文件。
import android.app.Activity;
import android.os.Bundle;
public class NewActivity extends Activity{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mian2);
}
}
xml文件代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.intentdemo2.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A new Activity has been started."
/>
</RelativeLayout>