1. Click the button to appear in the small window (response event)
How to configure:
Activity_main.xml file: <button (input) android:onclick= "Test1"/>
In the Mainactivity.java file:
public void test1 (view view) {
Toast.maketext (Mainactivity.this, "Contents of small Window", toast.length_shcrt (length of time shown)). Show ();
}
With each click, the button moves to the right 10 units (code below):
Dynamic mode:
Reusable mode (when multiple buttons are used to demonstrate their advantages):
Compare with HTML: Click Generate Small window
<script>
function test () {alert (123); }//Alert ("string");
</script>
<button onclick= "Test ()" > Test </button>
2. Click Toggle content, character address definition
Activity_main.xml file: <button (input) android:onclick= "Test2"/>
In the Mainactivity.java:
public void test2 (view view) {
Textview Textview = (Textview) Findviewbyid (R.ID.VIEW1);
Textview.settext ("Click to toggle Content");
}
Contrast HTML: Click to toggle Content
<button onclick= "Test ()" >test</button>
<span id= "AB" > I am a label </span>
<script>
function Test () {
var Ab=document.getelementbyid ("AB");
ab.innerhtml= "button click!!!";
}
</script>
Strings.xml in the values file, you can define a generic string (<string name= "tag name" > String content </string>), Call its contents directly: r.string. Tag name, call and name for button: android:text= "@string/Tag name"
There are also strings.xml in the Values-zh-rcn file, as well as the ability to define a string that, when both define the same name but differ in language, selects the appropriate language based on the language selected by the system.
3. Setting the background
Steps:
<1>. Save the picture in the Res/drawable file will love, if there is no drawable folder, you can create your own
<2> in Activity_main.xml,
<RelativeLayout>
android:background= "@drawable/Picture name"//drawable as folder name
</RelativeLayout>
<3>: Run code, test.
Android Notes-1