0
我在我的android測試應用程序開發期間運行代碼時出現錯誤。在FindBeerActivityAndroid編譯錯誤:無法找到符號類Textview
Error:(20, 9) error: cannot find symbol class Textview
Error:(20, 38) error: cannot find symbol method findViewByID(int)
Error:(22, 35) error: cannot find symbol method FindviewbyId(int)
Error:(24, 9) error: cannot find symbol class string
Error:(26, 9) error: cannot find symbol variable brnads
源代碼如下所示。
package com.hfad.beeradviser;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Spinner;
import android.widget.TextView;
public class FindBeerActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find_beer);
}
//Call when the button gets clicked
public void onClickFindBeer(View view) {
//get a reference to the Textview
Textview brands = (TextView) findViewByID(R.id.brands) ;
//get a reference to the Spinner
Spinner color = (Spinner) FindviewbyId(R.id.color);
//Get the selected item in the Spinner
string beerType = String.valueOf(color.getSelectedItem());
//Display the selected item
brnads.setText(beerType);
}
}
你能幫我解決這個錯誤嗎?
謝謝侯賽因,明白你的觀點,精美地工作。 –
不客氣。不要忘記投我的答案,並接受它,如果它解決了你的問題。 :) –