1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class HelloAndroid extends Activity
{
private Button bouton;
private TextView tv;
private Toast test;
private LinearLayout groupeDeVue;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
Toast.makeText(this, "huhu", 10);
super.onCreate(savedInstanceState);
tv = new TextView(this);
bouton = new Button(this);
bouton.setMinimumWidth(100);
bouton.setText("huhu");
bouton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
// Perform action on click
afficherNotif();
}
});
groupeDeVue = new LinearLayout(this);
groupeDeVue.addView(bouton);
groupeDeVue.addView(tv);
groupeDeVue.setOrientation(1);
setContentView(groupeDeVue);
tv.setText("Salut le monde");
}
public void afficherNotif()
{
test = Toast.makeText(this, "huhu", 10);
test.show();
}
} |