簡體   English   中英

我對課程概述做錯了什么?

[英]What i am doing wrong with Class Overview?

此代碼不起作用。 有人可以幫忙嗎?

.java

package rfmsoftware.util.test1;

import android.app.Activity;
import android.os.Bundle;

public class test1 extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button button = (Button)findViewById(R.id.Button01); <---- Error at this line !?

    }
}

.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"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
<EditText android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10"></EditText>
<Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/Scan"></Button>
<View android:id="@+id/View01" android:layout_width="wrap_content" android:layout_height="wrap_content"></View>
</LinearLayout>

。錯誤

按鈕無法解析為類型(Java類型問題)???

您需要import所需的Button類。

好。

我需要:import android.widget。*;

:P

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM