开发者

Android Add Link To Button

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开发者_JS百科.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.

Android Add Link To Button


Change your openWebUrl() method to match this, it will fix your problem.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜