活动布局未显示 [英] Activity layout not showing

查看:23
本文介绍了活动布局未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此代码从我的主活动中调用第二个活动

Im trying to call a second activity from my Main Activity, using this code

Intent goToOrder = new Intent(ListOfOrdersActivity.this, OrderSummaryActivity.class);
startActivity(goToOrder);

成为我的 OrderSummaryActivity:

Being my OrderSummaryActivity:

public class OrderSummaryActivity extends ActionBarActivity {

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

但布局不会显示在此活动中,只是一个空白页面.这是布局的xml:

But the layout wont show on this activity, just a blank page. This is the xml of the layout:

<?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>

有什么提示吗?

推荐答案

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

Try changing your OrderSummaryActivity.class to :

    public class OrderSummaryActivity extends ActionBarActivity
    {

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

这篇关于活动布局未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆