标签:出现 tools ast 要求 点击 china data dimen 测试
activity_main.xml
Design
main
上右键->New
->Activity
->点Gallery...
activity_third.xml
中修改text
信息进到MainActivity.java
中,加入代码
import android.content.Intent;
Intent intent = new Intent(this,ThirdActivity.class);
startActivity(intent);
效果如图:
在MainActivity.java
中加入代码
import android.widget.Toast;
Toast toast = Toast.makeText(MainActivity.this, "这是20165309吴思佳!", Toast.LENGTH_LONG);
toast.show();
及时截屏,如下:
activity_main.xml
的Design
下可以很容易地完成操作,改后的布局如下:MainActivity.java
package com.wsj.helloworld;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
int counter = 0;
int[] colors = { Color.BLACK, Color.BLUE, Color.CYAN,
Color.DKGRAY, Color.GRAY, Color.GREEN, Color.LTGRAY,
Color.MAGENTA, Color.RED, Color.WHITE, Color.YELLOW };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it
// is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
public void changeColor(View view) {
if (counter == colors.length) {
counter = 0;
}
view.setBackgroundColor(colors[counter++]);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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=".MainActivity">
<AnalogClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:id="@+id/analogClock1"
android:onClick="changeColor" />
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:layout_marginLeft="40dp" />
</RelativeLayout>
app
->Edit Configurations...
launch
选项下拉选择Nothing
.xml
的待错地方了,得挪回对应的文件夹下。File
->Invalidate Caches / Restart
,然后点击对话框中的 Invalidate and Restart
,清空cache
并且重启。按照老师的指导博客和电子书,我完成了本次实验,感觉很神奇,我什么时候能做到自己开发Android就更好了:)~
步骤 | 耗时 | 百分比 |
---|---|---|
需求分析 | 10min | 10 |
设计 | 20min | 20 |
代码实现 | 20min | 20 |
测试 | 30min | 30 |
分析总结 | 20min | 20 |
标签:出现 tools ast 要求 点击 china data dimen 测试
原文地址:https://www.cnblogs.com/wsj-wsj-wsj/p/9062180.html