第二种布局不会显示

时间:2012-05-29 02:50:44

标签: android android-layout android-emulator

我在模拟器中显示第二个布局时遇到了困难。

每个布局都有一个背景图片。第一种布局有2个附加图像(前向和后向图像)。按前向图像应显示第二个布局 但是,如果我删除图像并且只有一行文本,则会显示第二个布局。 因为我可以在用文本替换第二个布局的图像后显示它,我相信我可能会遇到内存大小问题。

这是内存问题吗?如果是这样,我该如何解决这个问题呢?

我在eclipse中使用API​​ 4(Android 1.6)的目标进行此操作。

测试代码......

清单          

<uses-sdk android:minSdkVersion="4" 
    android:targetSdkVersion="4" />

<application
    android:icon="@drawable/ic_launcher_dog"
    android:label="@string/app_name" >
    <activity
        android:name=".ScreenTestActivity"
        android:label="@string/app_name" 
        android:screenOrientation="landscape">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name="MainMenuActivity">
    </activity>

</application>

</manifest>

ScreenTestActivity:

public class ScreenTestActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // requesting to turn the title OFF  
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
    // making it full screen  
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // open view
        setContentView(R.layout.splash);

    //get the ImageView for the buttons
        ImageView iv_prev = (ImageView) findViewById(R.id.imagePageBack);
        ImageView iv_next = (ImageView) findViewById(R.id.imagePageForward);
    //set the listener
        iv_prev.setOnClickListener(this);
        iv_next.setOnClickListener(this);
}

public void onClick(View v) {

    switch(v.getId()){
        case R.id.imagePageBack:

            break;
        case R.id.imagePageForward:
            Intent i = new Intent(ScreenTestActivity.this, MainMenuActivity.class);
            startActivity(i);
            break;
    }
}
}

MainMenuActivity:

public class MainMenuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // requesting to turn the title OFF  
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
    // making it full screen  
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // open view
        setContentView(R.layout.main_menu);
}
}

这是splash.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:background="@string/background_image">

    <ImageView
        android:id="@+id/imagePageForward"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:src="@drawable/pageturn" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 
        android:layout_marginTop="-4dp" 
        android:layout_marginRight="-2dp"/>
    <ImageView
        android:id="@+id/imagePageBack"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:src="@drawable/pageturn_back" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentTop="true" 
        android:layout_marginTop="-4dp" 
        android:layout_marginLeft="-2dp"/>

</RelativeLayout>

0 个答案:

没有答案