Java 我能';t将视图添加到我的viewflipper
这是我的密码:Java 我能';t将视图添加到我的viewflipper,java,android,view,viewflipper,Java,Android,View,Viewflipper,这是我的密码: public View anEpisode(String n, String i, String d){ View v; LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = inflater.inflate(R.layout.episodedescription, null);
public View anEpisode(String n, String i, String d){
View v;
LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.episodedescription, null);
TextView nameOfEpisode = (TextView) findViewById(R.id.episodedescriptionname);
ImageView imageOfEpisode = (ImageView) findViewById(R.id.episodedescriptionimage);
TextView descriptionOfEpisode = (TextView) findViewById(R.id.episodedescriptiondescription);
nameOfEpisode.setText(n);
descriptionOfEpisode.setText(d);
createUrlImage(imageOfEpisode, i);
return v;
}
flipper.addView(anEpisode("test", "url image", "test description"));
我的错误在这行:
nameOfEpisode.setText(n);
你们能帮帮我吗?可能是因为我的充气机?我想你需要打电话给FindView查看充气机的结果。充气(注意v.):
您是否收到空引用异常?哦,我甚至没有注意到:/。谢谢
public View anEpisode(String n, String i, String d){
View v;
LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.episodedescription, null);
TextView nameOfEpisode = (TextView) v.findViewById(R.id.episodedescriptionname);
ImageView imageOfEpisode = (ImageView) v.findViewById(R.id.episodedescriptionimage);
TextView descriptionOfEpisode = (TextView) v.findViewById(R.id.episodedescriptiondescription);
nameOfEpisode.setText(n);
descriptionOfEpisode.setText(d);
createUrlImage(imageOfEpisode, i);
return v;
}
flipper.addView(anEpisode("test", "url image", "test description"));