<RelativeLayout xmlns:android="[Link]
com/apk/res/android"
xmlns:tools="[Link]
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=".MainActivity">
<Button
android:id="@+id/simpleButton1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:background="#00f"
android:drawableRight="@drawable/ic_launcher"
android:hint="AbhiAndroid Button1"
android:padding="5dp"
android:textColorHint="#fff"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:id="@+id/simpleButton2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#f00"
android:drawableLeft="@drawable/ic_launcher"
android:hint="AbhiAndroid Button2"
android:padding="5dp"
android:textColorHint="#fff"
android:textSize="20sp"
android:textStyle="bold|italic" />
</RelativeLayout>
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
Button simpleButton1, simpleButton2;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
simpleButton1 = (Button) findViewById([Link].simpleButton1);//get id of
button 1
simpleButton2 = (Button) findViewById([Link].simpleButton2);//get id of
button 2
[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link](getApplicationContext(), "Simple Button 1", To
ast.LENGTH_LONG).show();//display the text of button1
}
});
[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link](getApplicationContext(), "Simple Button 2", To
ast.LENGTH_LONG).show();//display the text of button2
}
});
}