Donc, je suis assez nouveau à toute cette chose de développement pour Android et je ne connais pas une nappe de Java. J'essaye de m'enseigner ceci donc j'ai pensé que ce serait une grande ressource. J'ai lu les ressources devoloper.android et je ne comprends toujours pas alors voici ma question. Je fais une application simple qui va changer la couleur de fond quand le bouton est pressé. Comment puis-je faire le bouton faire cela?Contrôle de bouton?
Les ressources extérieures/exemples seraient grandement appréciés
Voici mon code à ce jour:
IntroActivity.java
package com.flashcalc;
import android.app.Activity;
import android.os.Bundle;
import android.view.View.OnTouchListener;
import android.widget.Button;
public class IntroActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/all_white">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:textColor="@color/all_black"
android:gravity="center_horizontal"/>
<Button android:text="@string/ChangeColor"
android:id="@+id/ChangeColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_horizontal|center"
android:layout_gravity="center_horizontal|center_horizontal|center">
</Button>
</LinearLayout>
Strings. xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Tjs Flashlight</string>
<string name="app_name">FlashCalc</string>
<string name="ChangeColor">I Love Buttons</string>
<color name="all_white">#FFFFFF</color>
<color name="all_black">#000000</color>
</resources>