Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Inherited from android.view.View Class:<br />
Attribute<br />
android:background<br />
android:contentDescription<br />
android:id<br />
android:onClick<br />
android:visibility<br />
Description<br />
This is a drawable to use as the background.<br />
This defines text that briefly describes content of the view.<br />
This supplies an identifier name for this view,<br />
This is the name of the method in this View's context to invoke when the view is<br />
clicked.<br />
This controls the initial visibility of the view.<br />
Example<br />
This example will take you through simple steps to show how to create your own <strong>Android</strong> application using Linear<br />
Layout and EditText.<br />
Step Description<br />
1<br />
You will use Eclipse IDE to create an <strong>Android</strong> application and name it as GUIDemo2 under a<br />
package com.example.guidemo2 as explained in the Hello World Example chapter.<br />
2 Modify src/MainActivity.java file to add a click event.<br />
2 Modify the detault content of res/layout/activity_main.xml file to include <strong>Android</strong> UI control.<br />
3 Define required constants in res/values/strings.xml file<br />
4 Run the application to launch <strong>Android</strong> emulator and verify the result of the changes done in the application.<br />
Following is the content of the modified main activity filesrc/com.example.guidemo2/MainActivity.java. This file<br />
can include each of the fundamental lifecycle methods.<br />
package com.example.guidemo2;<br />
import android.os.Bundle;<br />
import android.app.Activity;<br />
import android.view.Menu;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
import android.widget.Toast;<br />
public class MainActivity extends Activity {<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.activity_main);<br />
final EditText eText;<br />
final Button btn;<br />
eText = (EditText) findViewById(R.id.edittext);<br />
btn = (Button) findViewById(R.id.button);<br />
btn.setOnClickListener(new OnClickListener() {<br />
TUTORIALS POINT<br />
Simply Easy Learning