Main1.xml
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:orientation=”vertical” >
<EditText
android:id=”@+id/editText1″
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:ems=”10″ >
<requestFocus />
</EditText>
<EditText
android:id=”@+id/editText2″
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:ems=”10″ />
<Button
android:id=”@+id/button1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:onClick=”onMyClick”
android:text=”@string/bt1name”
android:background=”@drawable/bgred” />
<Button
android:id=”@+id/button2″
android:layout_height=”wrap_content”
android:text=”@string/message1″
android:layout_width=”@dimen/b2name”/>
<EditText
android:id=”@+id/editText3″
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:ems=”10″
android:textColor=”@color/etred” />
<ImageView
android:id=”@+id/imageView1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/penguins” />
</LinearLayout>
——————————————————-
MainActivity.Java
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
setContentView(R.layout.main1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public void onMyClick(View view)
{
Toast.makeText(this, this.getString(R.string.message1),
Toast.LENGTH_LONG).show();
}
Result After Run