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方法。用那个