当我点击按钮时,它只显示白色屏幕而不是下一个活动的视图.我找不到为什么会发生请给我解决方案......我的整个代码就在这里
ActivityMain.java
package com.rahul.intentswitchingwithdata;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void go(View v){
Intent i= new Intent(this,Next.class);
startActivity(i);}
}
Run Code Online (Sandbox Code Playgroud)
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rahul.intentswitchingwithdata.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="go"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Next.java
public class Next extends Activity {
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle
persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.next);
}
}
Run Code Online (Sandbox Code Playgroud)
next.xml …
android ×1