任何人都可以幫助保持收到此錯誤 即時得到它在這行代碼Android的 - 方法findViewById(INT)是未定義的類型
TextView t1 = (TextView)findViewById(R.id.textCocktailName);
下面是完整的代碼片段:
package com.drunktxtapp;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.view.View.OnClickListener;
import android.content.Intent;
import android.widget.TextView;
import android.view.View;
public class CocktailDetail {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bloody_mary);
ImageView imageView1 = (ImageView)findViewById(R.id.imageCocktail);
imageView1.setImageDrawable(getResources().getDrawable(R.drawable.bloodymary));
Button b1 = (Button) findViewById(R.id.bYoutube);
TextView t1 = (TextView) findViewById(R.id.textCocktailName);
String cocktailName = getIntent().getStringExtra("Bloody Mary");
t1.setText(cocktailName);
b1.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=Alt-ehDc3fc")));
}
});
}
}
1)做一個乾淨的構建。 2)發佈bloody_mary.xml 乾杯! – mach
您應該標記爲正確的答案 – Daniel