0% found this document useful (0 votes)
3 views2 pages

button.docx

The document is a Java code for an Android application that defines a MainActivity class. It sets up a button that, when clicked, displays a Toast message saying 'Hello Javapoint'. The activity also includes a method to create an options menu.

Uploaded by

aswinakbca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

button.docx

The document is a Java code for an Android application that defines a MainActivity class. It sets up a button that, when clicked, displays a Toast message saying 'Hello Javapoint'. The activity also includes a method to create an options menu.

Uploaded by

aswinakbca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

package com.example.

firstactivity;

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.view.View;

import android.widget.Button;

import android.widget.Toast;

public class MainActivity extends Activity {

​ Button button;

​ @Override

​ protected void onCreate(Bundle savedInstanceState) {

​ ​ super.onCreate(savedInstanceState);

​ ​ setContentView(R.layout.activity_main);

​ ​ button=(Button)findViewById(R.id.button1);

​ ​ button.setOnClickListener(new View.OnClickListener() {

​ ​ ​

​ ​ ​ @Override

​ ​ ​ public void onClick(View view) {

​ ​ ​ ​ Toast.makeText(getApplicationContext(),"Hello
Javapoint",Toast.LENGTH_SHORT).show();

​ ​ ​ ​ // TODO Auto-generated method stub

​ ​ ​ ​

​ ​ ​ }
​ ​ });

​ ​ ​ ​

​ }

​ @Override

​ public boolean onCreateOptionsMenu(Menu menu) {

​ ​ // Inflate the menu; this adds items to the action bar if it is present.

​ ​ getMenuInflater().inflate(R.menu.main, menu);

​ ​ return true;

​ }

You might also like