android - How to move from one Activity to another in Eclipse ADT? -


How do we move from one activity (Welcome) into another (tutorial) by pressing a button?

Welcome here. Java File:

  Package Com Ancient architecture; Importroid.os.Bundle; Import android.support.v4.app.Fragment; Import android.support.v7.app.ActionBarActivity; Import android.view.LayoutInflater; Import android.view.View; Import android.view.ViewGroup; Welcome to the Public Sector ActionBarActivity {@Override Creates Secure Zero (Bundle Saved InstantState) {super.onCreate (SavedInstanceState); SetContentView (R.layout.welcome); If (savedInstanceState == zero) {getSupportFragmentManager () BeginTransaction () .add (R.id.container, new placeholder fragment ()). Commit (); }} / ** * A placeholder piece in which there is a simple view * / public static class PlaceholderFragment piece {public PlaceholderFragment {} @Override Public View onCreateView (LayoutInflater inflater, ViewGroup container, savedInstanceState bundle) {see rootView = inflater.inflate (R.layout.fragment_welcome, container, wrong) is extensively; Return root view; }}}   

Here's my tutorial. Java:

  package com.rippledirectory; Import android.support.v7.app.ActionBarActivity; Import android.support.v4.app.Fragment; Importroid.os.Bundle; Import android.view.LayoutInflater; Import android.view.View; Import android.view.ViewGroup; Public Class Tutorial ActionBarActivity {@Override Expands Create (Bundle Saved Instantstate) on Protected Zero {Super. Connet (Saved Instantstate); SetContentView (R.layout.tutorial); If (savedInstanceState == zero) {getSupportFragmentManager () BeginTransaction () .add (R.id.container, new placeholder fragment ()). Commit (); }} / ** * A placeholder slice that has a simple view * / public static class PlaceholderFragment piece {Public PlaceholderFragment () {} @Override Public View onCreateView (LayoutInflater inflater, ViewGroup container, savedInstanceState) {View rootView = inflater.inflate (R.layout.fragment_tutorial, Container, Wrong) is extensively; Return root view; }}}   

Here is my app manifest file:

   & Lt; Application: Android: allowBackup = "true" Android: Icon = "@ drawable / ic_launcher" Android: label = "@ string / app_name" Android: theme = "@ style / appTheme" Android: permission = "android.permission.INTERNET" & permission Gt; & Lt; Activity Android: name = "com.rippledirectory.Welcome" android: label = "@ string / app_name" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.MAIN" /> & Lt; Category android: name = "android.intent.category.LAUNCHER" /> & Lt; / Intent-Filter & gt; & Lt; / Activity & gt; & Lt; Activity Android: name = "com.rippledirectory.Tutorial" Android: label = "@ string / title_activia_tutorial" Android: parentActivityName = "com.rippledirectory.Welcome" & gt; & Lt; Meta-Data Android: name = "android.support.PARENT_ACTIVITY" Android: value = "com.rippledirectory.Welcome" /> & Lt; / Activity & gt; & Lt; / Application & gt; & Lt; / Reveal & gt;    

This is really simple and basic question! It looks like there is more to study before creating an Android app. Anyway, tell the answer :)

First, create a button in the welcome.xml layout file.

  & lt; linearLayout xmlns: android = "http: // schema .android.com / apk / rij / android" Android: layout_width = "filled_preview" Android: layout_heil = "fill_preview" Android: orientation = "vertical" & gt; & Lt; Button Android: ID = "@ + ID / Button 1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: text = "button" /> & Lt; / LinearLayout & gt;   

Second, declare the button object to welcome.java.

  private button goTutorialBTN;   

Third, the welcome button object in welcome.java.

  Protected over @OverrideCreate (bundled saved instenstate) {super.onCreate (savedInstanceState); SetContentView (R.layout.welcome); goTutorialBTN = (Find Button) ViewById (R.id.button1); goTutorialBTN.setOnClickListener (New OnClickListener) {@Override Public Zero onClick (see v) {intent = new intent (Welcome.this, Tutorial.class); startActivity;}}); }}   

Thanks!

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -