0

我正在开发一个链接到同一视图中的视频和网站的应用程序。我遇到的问题是如何将视频和链接同时链接到不同的视图。这是我到目前为止所拥有的:

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);
    }
}

视频按钮工作正常,但链接按钮根本不起作用。这是我运行它时的样子。

请链接帮助!

4

1 回答 1

2

更改您的 openWebUrl() 方法以匹配此,它将解决您的问题。

public void openWebURL(String fullUrl){
    Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(fullUrl));
    startActivity(intent);
}
于 2011-09-07T14:33:34.773 回答