2011-07-14 14 views
0

ここに問題があります。エミュレータでアプリケーションを実行すると、xmlの私のUI要素が表示されません。xmlのUi要素がエミュレータに表示されませんか?

public void OnCreate(Bundle savedInstanceState){ 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.single_coll); 

     Button one = (Button) findViewById(R.id.all_stampii); 
     one.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
       Intent intent = new Intent(v.getContext(), AllStampii.class); 
       startActivity(intent); 
      } 

     });} 

single_coll.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <Button android:text="All Stampii" android:id="@+id/all_stampii" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 
    <Button android:text="Owned" android:id="@+id/owned" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 
    <Button android:text="Repeated" android:id="@+id/repeated" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 
    <Button android:text="Last Acquired" android:id="@+id/last_ac" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 

</LinearLayout> 

エラーはありません。私はちょうどこのクラスで、エミュレータでUi要素を見ることができません。 提案がありますか?

答えて

2

私はあなたが関数宣言で小さな問題があると思います。あなたが持っていることは次のとおりです。

public void OnCreate(Bundle savedInstanceState) 

「のonCreate」「OnCreate関数」にしてくださいと宣言する前に@Overrideを置きます。

+0

ええ、それが問題だったと呼ばれる...どうもありがとう! – hardartcore

+0

ようこそ。この回答を投票することを検討してください。 – Khawar

2

あなたはonCreateメソッドをオーバーライドしているようではありません。つまり、そこにあるOnCreateメソッドが起動時に呼び出されていないということです。 あなたが (のonCreateで「O」小文字に注意してください)

@Override 
public void onCreate(Bundle savedInstance){ 

に最初の行を変更する場合は、この方法が正しく

関連する問題