Android第一个HelloWorld

修改布局文件app/res/layout/activity_main.xml

1.拖入TextView`Button`,生成代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:text="button"
app:layout_constraintTop_toBottomOf="@+id/textView"
tools:layout_editor_absoluteX="43dp" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:text="TextView"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="43dp" />

2.修改app/java/MainACtivity

1
2
TextView tv= (TextView)this.findViewById(R.id.textView);
tv.setText("我的第一个安卓程序:hello world");

3.连接mumu模拟器

adb connect 127.0.0.1:7555