Nimbuzzmasters forum
nwlve HI   GUEST nwlve
WELCOME TO NIMBUZZ MASTERS FORUM
PLEASE   REGISTER

TO
Dzs HAVE FULL ACCESS TO THE FORUM AND BE ABLE TO DOWNLOAD STUFF Dzs
Grp
STAY WITH US THANK YOU
Forum management ©
Mzs

Tutorial: Android: button_ul Android

View previous topic View next topic Go down

avatar
Aaryan
Member
Member
Join date : 2012-12-16
Posts : 63
Thanks gained - : 1240
Gender : Male
Age : 28
Location Location : India
View user profile

PostAaryan on Sun Feb 26, 2017 7:49 am

MainActivity

LOCATION: java/MainActivity.java
Code:
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;

public class MyAndroidAppActivity extends Activity {

Button button;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

addListenerOnButton();

}

public void addListenerOnButton() {

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

button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);

}
});
}
}
activity_main

LOCATION: res/layout/activity_main.xml
Code:
<LinearLayout xmlns:android="http:// schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_gravity="center_horizontal"/>

</LinearLayout>

avatar
TOP-CODER
Management team
Management team
Join date : 2012-11-07
Posts : 400
Thanks gained - : 2895
Gender : Male
Age : 28
Location Location : india
View user profile http://www.hackersw0rld.tk

PostTOP-CODER on Tue Feb 28, 2017 7:33 pm

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum