ArhamTechMind

Button

Button Example 2

MainActivity.java package com.blogspot.csdevbin.mynewpractice; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class MainActivity extends AppCompatActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         B1();     }     private void B1() {         Button b1 = (Button) findViewById(R.id.button1);         b1.setOnClickListener(new View.OnClickListener() {             @Override             public void …

Button Example 2 Read More »

Working with Multiple Button Android Example

Multiple Button Example activity_main.xml<?xml version=”1.0″ encoding=”utf-8″?><RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”    xmlns:tools=”http://schemas.android.com/tools”    android:layout_width=”match_parent”    android:layout_height=”match_parent”    android:paddingBottom=”@dimen/activity_vertical_margin”    android:paddingLeft=”@dimen/activity_horizontal_margin”    android:paddingRight=”@dimen/activity_horizontal_margin”    android:paddingTop=”@dimen/activity_vertical_margin”    tools:context=”com.example.desktop.buttonexample.MainActivity”>     <Button        android:layout_width=”wrap_content”        android:layout_height=”wrap_content”        android:text=”button 1″        android:id=”@+id/button1″        android:layout_marginTop=”53dp”        android:layout_alignParentTop=”true”        android:layout_alignLeft=”@+id/button2″  …

Working with Multiple Button Android Example Read More »

Android Button Example

MainActivity.java package com.example.desktop.buttonexample;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.Toast;public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button btn =(Button)findViewById(R.id.button); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(MainActivity.this,”Button clicked”,Toast.LENGTH_SHORT).show(); } }); }} activity_maain.xml <?xml version=”1.0″ encoding=”utf-8″?><RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:paddingBottom=”@dimen/activity_vertical_margin” android:paddingLeft=”@dimen/activity_horizontal_margin” android:paddingRight=”@dimen/activity_horizontal_margin” android:paddingTop=”@dimen/activity_vertical_margin” tools:context=”com.example.desktop.buttonexample.MainActivity”> <Button android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”button” android:id=”@+id/button” android:layout_alignParentTop=”true” …

Android Button Example Read More »