Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 活动布局未显示_Java_Android_Android Studio - Fatal编程技术网

Java 活动布局未显示

Java 活动布局未显示,java,android,android-studio,Java,Android,Android Studio,我正在尝试调用主活动中的第二个活动,使用以下代码 Intent goToOrder = new Intent(ListOfOrdersActivity.this, OrderSummaryActivity.class); startActivity(goToOrder); 作为我的订单摘要活动: public class OrderSummaryActivity extends ActionBarActivity { @Override public void onCreat

我正在尝试调用主活动中的第二个活动,使用以下代码

Intent goToOrder = new Intent(ListOfOrdersActivity.this, OrderSummaryActivity.class);
startActivity(goToOrder);
作为我的订单摘要活动:

public class OrderSummaryActivity extends ActionBarActivity {

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(R.layout.order_summary);
    }
}
但版面不会显示在本次活动中,只是一个空白页。 这是布局的xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/name"
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_margin="10dp"
        />
    <TextView
        android:id="@+id/order_resume_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/quantity"
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_margin="10dp"/>
    <TextView
        android:id="@+id/order_resume_quantity"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/whipped_cream"
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_margin="10dp"/>
    <TextView
        android:id="@+id/order_resume_whipped_cream"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/chocolate"
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_margin="10dp"/>
    <TextView
        android:id="@+id/order_resume_chocolate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/order_summary_total"
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_margin="10dp"/>
    <TextView
        android:id="@+id/order_resume_total"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


</LinearLayout>

有任何提示吗?

尝试覆盖

public void onCreate(Bundle savedInstanceState)
而不是

public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState)

尝试将您的OrderSummaryActivity.class更改为:

    public class OrderSummaryActivity extends ActionBarActivity
    {

        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.order_summary);
        }
    }

必须有另一个onCreate方法。用那个