Contact for Android Technical support, Free lancing and online training +919133711199, Email id: rams4android@gmail.com
Tuesday, 15 January 2013
Working with Button(Anonymous Inner Type)
ScreenShots:
activity_main.xml:
<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"
tools:context=".MainActivity" >
<Button
android:id="@+id/clickMeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="111dp"
android:layout_marginTop="54dp"
android:text="Click Me" />
</RelativeLayout>
MainActivity.java:
package com.ram.buttonanonymustype;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button clickButton = (Button)findViewById(R.id.clickMeButton);
clickButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "button is working", 3000).show();
}
});
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment