navigieren Sie von einer Seite zur anderen

Ich bin neu mit android dies ist mein 1. demo-app. Ich bin versucht, navigieren Sie von einer Seite zur anderen. Aber ich bin nicht in der Lage, navigieren zu einer anderen Seite habe ich einen Knopf im Mai Haupt-xml-Datei und lecken es sich um ein anderes xml-nextpage. Ich habe 2 java-Klasse : 1. MianAcitvity, nextpagejava. 2 xml : activity_main, nextpage

Mein code : manifest

    <activity
        android:name="com.example.androiddemo.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="nextpagejava" ></activity>

MainActivity.java

package com.example.androiddemo;
import android.os.Bundle; 
import android.app.Activity; 
import android.content.Intent; 
import android.drm.DrmStore.Action;
 import android.view.Menu; 
import android.view.View; 
import android.view.View.OnClickListener; 
 import android.widget.Button;

     public class MainActivity extends Activity implements OnClickListener {

      @Override
      protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);

           Button bt = (Button)findViewById(R.id.bnt);
           bt.setOnClickListener(new View.OnClickListener() {

           @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub

           }
         }); 
         }

          @Override
          public boolean onCreateOptionsMenu(Menu menu) {
          //Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
         }

          @Override
          public void onClick(View v) {
          //TODO Auto-generated method stub
          switch(v.getId()){
          case R.id.bnt:
                 Intent in = new Intent(this, nextpagejava.class);
                 startActivity(in);
             break;


          }
          }
          }

acitivity_main.xml

       <LinearLayout  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:id="@+id/clicktxt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Click"        
        />

        <Button
        android:id="@+id/bnt"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Click Me"
        />

kann mir jemand sagen, was ich falsch mache?

InformationsquelleAutor Anu0042 | 2013-01-09
Schreibe einen Kommentar