Android添加链接到按钮

时间:2011-09-07 14:25:08

标签: android streaming hyperlink media android-button

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

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

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

Link Help Please!

1 个答案:

答案 0 :(得分:2)

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

public void openWebURL(String fullUrl){
    Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(fullUrl));
    startActivity(intent);
}