Acivity_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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
MainActivity.java
package com.example.act;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.Toast;
public class MainActivity extends
Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(this,"onCreate", Toast.LENGTH_LONG).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
protected void onStart() {
super.onStart();
Toast.makeText(this,"onStart", Toast.LENGTH_LONG).show();
}
protected void onPause() {
super.onPause();
Toast.makeText(this,"onPause", Toast.LENGTH_LONG).show();
}
protected void onStop() {
super.onStop();
Toast.makeText(this,"onStop", Toast.LENGTH_LONG).show();
}
protected void onResume() {
super.onResume();
Toast.makeText(this,"onResume", Toast.LENGTH_LONG).show();
}
protected void onDestroy() {
super.onDestroy();
Toast.makeText(this,"onDestroy", Toast.LENGTH_LONG).show();
}
protected void onRestart()
{
super.onRestart();
Toast.makeText(this,"onRestart", Toast.LENGTH_LONG).show();
}
}
0 Comments