任何人都可以帮助不断收到此错误我在这行代码中得到它
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")));
}
});
}
}