2013-08-05 46 views
1

我使用Nexus Emulator開發了一個簡單的Hello World示例。模擬器運行但是當我點擊模擬器上的鎖定按鈕時,圖形佈局不顯示。在Eclipse中顯示的圖形佈局但在仿真器運行時不顯示

MY MainActivity.Java文件的源代碼在這裏

package com.myNewProject.helloworld; 

import android.os.Bundle; 

import android.app.Activity; 
import android.view.Menu; 



public class MainActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 


    } 


    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 

} 

activity_main.xml中文件的代碼

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:contentDescription="@string/hello_world" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/hello_world" /> 

</RelativeLayout> 

我已經運行模擬器多次。

回答

0

你是否在android清單文件中啓動它?你必須在那裏發射。謝謝 這裏是一個例子..

 <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
相關問題