布局元素没有显示出来

Joe*_*Joe 0 xml layout android

我有两个活动,第一个是正确生成,但第二个不是.只显示xml文件中的第一个元素.这是我的xml文件:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/alternateActivity"
    android:shadowColor="@color/shadowColor"></TextView>
<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/oldActivityButton"
    android:text="@string/oldActivityButton"></Button>
<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/changeText"
    android:text="@string/changeTextButton"></Button>
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/originalText" 
    android:id="@+id/textToChange"></TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的活动对应:

package fsg.dev.activitytest;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class newActivity extends Activity {
private Button oldActivityButton;
private Button changeText;
private TextView textToChange;

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

        oldActivityButton = (Button) findViewById(R.id.oldActivityButton);
        changeText = (Button) findViewById(R.id.changeText);
        textToChange = (TextView) findViewById(R.id.textToChange);

        oldActivityButton.setOnClickListener(new OnClickListener(){
        public void onClick(View view){
            changeActivity();
        }
        });
        changeText.setOnClickListener(new OnClickListener(){
        public void onClick(View view){
            changeText();
        }
        });
    }

    private void changeActivity(){
        Intent i = new Intent(this, activityTest.class);
        startActivity(i);
    }

    private void changeText(){
        if(textToChange.equals(R.string.originalText)){
        textToChange.setText(R.string.newText);
        } else {
        textToChange.setText(R.string.originalText);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有人见过这个问题?或知道一种解决方法?

Kar*_*Øie 5

尝试将android:orientation ="vertical"添加到LinearLayout