android-start-activity
android-start-activity
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.hmkcode.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class AnotherActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_another);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.hmkcode.android;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
|
||||
public class MainActivity extends Activity implements OnClickListener {
|
||||
|
||||
Button btnStartAnotherActivity;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
btnStartAnotherActivity = (Button) findViewById(R.id.btnStartAnotherActivity);
|
||||
|
||||
btnStartAnotherActivity.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
Intent inent = new Intent(this, AnotherActivity.class);
|
||||
|
||||
// calling an activity using <intent-filter> action name
|
||||
// Intent inent = new Intent("com.hmkcode.android.ANOTHER_ACTIVITY");
|
||||
|
||||
startActivity(inent);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user