Android 添加链接到按钮
我正在开发一个在同一视图中链接到视频和网站的应用程序。我遇到的问题是如何同时链接视频和链接以分离视图。这就是我到目前为止所拥有的:
private String videoUrl;
private String fullUrl;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.details);
TextView detailsTitle = (TextView)findViewById(R.id.detailstitle);
TextView detailsDescription = (TextView)findViewById(R.id.detailsdescription);
TextView detailsPubdate = (TextView)findViewById(R.id.detailspubdate);
TextView detailsLink = (TextView)findViewById(R.id.detailslink);
TextView detailsEnclosure = (TextView)findViewById(R.id.detailsenclosure);
Button linkButton = (Button)findViewById(R.id.linkButton);
View VideoPlay = findViewById(R.id.videoButton);
VideoPlay.setOnClickListener(this);
Bundle bundle = this.getIntent().getExtras();
detailsTitle.setText(bundle.getString("keyTitle"));
detailsDescription.setText(bundle.getString("keyDescription"));
detailsPubdate.setText(bundle.getString("keyPubdate"));
detailsLink.setText(bundle.getString("keyLink"));
linkButton.setText("View this in full website");
videoUrl = bundle.getString("keyEnclosure");
fullUrl = bundle.getString("keyLink");
}
//Process the button click events
public void onClick(View videoplayer) {
Intent VideoPlay = new Intent(this, VideoPlayer.class);
VideoPlay.putExtra("url",videoUrl);
startActivity(VideoPlay);
}
public void openWebURL(String fullUrl){
Intent Browse = new Intent(Intent.ACTION_VIEW, Uri.parse (fullUrl));
Browse.putExtra(com.CalvaryChapelMelbourne.CCM.Webscreen.URL,
"fullUrl");
startActivity(Browse);
}
}
视频按钮工作正常,但链接按钮根本不起作用。这就是我运行它时的样子。
I am working on an app that links to a video and a website in the same view. The problem I am having is how to link the video and the link at the same time to separate views. This is what I have so far:
private String videoUrl;
private String fullUrl;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.details);
TextView detailsTitle = (TextView)findViewById(R.id.detailstitle);
TextView detailsDescription = (TextView)findViewById(R.id.detailsdescription);
TextView detailsPubdate = (TextView)findViewById(R.id.detailspubdate);
TextView detailsLink = (TextView)findViewById(R.id.detailslink);
TextView detailsEnclosure = (TextView)findViewById(R.id.detailsenclosure);
Button linkButton = (Button)findViewById(R.id.linkButton);
View VideoPlay = findViewById(R.id.videoButton);
VideoPlay.setOnClickListener(this);
Bundle bundle = this.getIntent().getExtras();
detailsTitle.setText(bundle.getString("keyTitle"));
detailsDescription.setText(bundle.getString("keyDescription"));
detailsPubdate.setText(bundle.getString("keyPubdate"));
detailsLink.setText(bundle.getString("keyLink"));
linkButton.setText("View this in full website");
videoUrl = bundle.getString("keyEnclosure");
fullUrl = bundle.getString("keyLink");
}
//Process the button click events
public void onClick(View videoplayer) {
Intent VideoPlay = new Intent(this, VideoPlayer.class);
VideoPlay.putExtra("url",videoUrl);
startActivity(VideoPlay);
}
public void openWebURL(String fullUrl){
Intent Browse = new Intent(Intent.ACTION_VIEW, Uri.parse (fullUrl));
Browse.putExtra(com.CalvaryChapelMelbourne.CCM.Webscreen.URL,
"fullUrl");
startActivity(Browse);
}
}
The video button works fine, but the link button doesn't work at all. This is what it looks like when I run it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改您的 openWebUrl() 方法以匹配此方法,它将解决您的问题。
Change your openWebUrl() method to match this, it will fix your problem.