视频活动
你给我的代码包含在videoactivity中,我在行私有字符串VIDEO = url的网址上出现错误;告诉我,url无法解析为变量
public class VideoActivity extends YouTubeBaseActivity implements
YouTubePlayer.OnInitializedListener {
static private final String DEVELOPER_KEY = "AIzaSyBR-QH8hCO8U_WE_sIPGhEQIGmBEYCi7pQ";
private String VIDEO = url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videoactivity);
YouTubePlayerView youTubeView = (YouTubePlayerView)
findViewById(R.id.youtube_video);
youTubeView.initialize(DEVELOPER_KEY, this);
Bundle bundle = getIntent().getExtras();
final String url = bundle.getString("url1");
}
public void onInitializationFailure(Provider provider,
YouTubeInitializationResult error) {
Toast.makeText(this, "Oh no! Errore di Connessione, provi a rientrare"+error.toString(),
Toast.LENGTH_LONG).show();
}
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player,
boolean wasRestored) {
player.loadVideo(VIDEO);
}
}
答案 0 :(得分:1)
使用:
Intent video = new Intent(EpisodiActivity.this,VideoActivity.class);
video.putExtra("url", "value");
startActivity(video);
同样在你上课:
mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
Intent video = new Intent(EpisodiActivity.this,VideoActivity.class);
String urlFromListView=(String)arg0.getItemAtPosition(position);
video.putExtra("url",urlFromListView);
startActivity(video);
}
});
要在VideoActivity
中找回它:
onCreate(Bundle savedInstanceState)
之后的setContentView(R.layout.videoactivity);
内
Bundle bundle = getIntent().getExtras();
final String url = bundle.getString("url");