package my.hello.world;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class HelloWorldActivity extends Activity {
/** Called when the activity is first created. */
Button hello;
TextView txt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hello=(Button) findViewById(R.id.hello);
txt=(TextView) findViewById(R.id.txt);
hello.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
txt.setText("Hello world");
}
});
}
}
In above example we see that we used one TextView and one Button.
On the Button onclicklistener activity we simply set the Text as "Hello World" .
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class HelloWorldActivity extends Activity {
/** Called when the activity is first created. */
Button hello;
TextView txt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hello=(Button) findViewById(R.id.hello);
txt=(TextView) findViewById(R.id.txt);
hello.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
txt.setText("Hello world");
}
});
}
}
In above example we see that we used one TextView and one Button.
On the Button onclicklistener activity we simply set the Text as "Hello World" .
No comments:
Post a Comment