ad728

Tuesday, May 22, 2018

AIDE Tutorial - 57 Open another Activity

AIDE Tutorial - 57 Open another Activity

Watch the video below
Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <Button
android:id="@+id/mainButton"
        android:text="Open another Activity"
        android:layout_width="wrap_content"        android:layout_height="wrap_content" />
</LinearLayout>
Second.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    <TextView
android:text="This is the second activity"
android:layout_width="wrap_content"android:layout_height="wrap_content"/>
</LinearLayout>
MainActivity.java
package com.kcgroup.anotheractivity;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{    @Override
    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
Button btn=(Button)findViewById(R.id.mainButton);
btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1)
{Intent in=new Intent(MainActivity.this, SecondActivity.class);
startActivity(in);
// TODO: Implement this method
}});    }}
SecondActivity.java
package com.kcgroup.anotheractivity;
import android.app.*;
import android.os.*;
public class SecondActivity extends Activity
{    @Override
    protected void onCreate(Bundle savedInstanceState)
    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
    }}
Share:

1 comment:

Total Pageviews

Sponsor

Sponsor

ad300